title: SQL - Select IDs from two different tables
body: <p>I have two tables that have logging information for different actions. I want to select information from both logging tables and display it. I cannot modify the application, so I can't modify the table structure. Assuming I wanted, say, 30 records, I figured I could write some kind of join query that would just return the IDs for each table, in order by time. Then I could simply run two separate queries selecting those IDs from the individual tables. I'm not sure how to do this, or if you even can do this, and I'm kind of at a loss. Can anyone help? If there's a cleaner solution I'd be happy to hear that as well, I'm working in PHP.</p>
  
  <p>Example data:</p>
  
  <p>MAGICAL SELECT ? FROM table1 MAGIC JOIN table2 MAGICALLY ORDER BY date DESC LIMIT 3</p>
  
  <p>Table 1</p>
  
  <pre><code>|------|-------|------------|
  | id   | date  | other data |
  |------|-------|------------|
  | 1    | 8     | ...        |
  | 2    | 5     | ...        |
  | 3    | 3     | ...        |
  |------|-------|------------|
  </code></pre>
  
  <p>Table 2</p>
  
  <pre><code>|------|-------|------------|
  | id   | date  | other data |
  |------|-------|------------|
  | 1    | 6     | ...        |
  | 2    | 4     | ...        |
  | 3    | 12    | ...        |
  |------|-------|------------|
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>|-----------|-----------|
  | table1_id | table2_id |
  |-----------|-----------|
  | NULL      | 3         |
  | 1         | NULL      |
  | NULL      | 1         |
  |-----------|-----------|
  </code></pre>
  
  <p>Thanks in advance.</p>