title: Output Data From Two Tables With Identical Columns And Add Variable As Identifier
body: <p>Lets say I have two tables, with identical column names, and when I want to output them into a table, I simply want an additional field to show the user which table it came from...
  i.e.</p>
  
  <h3>Table1</h3>
  
  <pre><code>---------------------------------------------------
  ID| name | address | another_identifier|  color
  -------------------------------------------------
  1 | Bob  | 123 Nowhere | 12345         |  gray
  2 | Jane | 321 nowhere | 54321         |  red
  3 | Jack | 555 somewhere | 12993       |  blue
  </code></pre>
  
  <h3>Table2</h3>
  
  <pre><code>------------------------------------------------
  ID| name | address | another_identifier|  color
  ------------------------------------------------
  1 | Bob  | 123 Nowhere | 12345         | purple
  2 | Jane | 321 nowhere | 54321         | green
  3 | Jack | 555 somewhere | 12993       | blue
  </code></pre>
  
  <h3>Query</h3>
  
  <pre><code>$query = "SELECT a.*, b.* FROM table1 a, table2 b";
  $results = $class-&gt;runQuery($query); // basically a fetchAll to create an array
  </code></pre>
  
  <h3>Display Code</h3>
  
  <pre><code>foreach($results as $row){          
  $html .= "&lt;tr&gt;";
  //Now print the name            
  $html .= "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;";
  // Print the address
  $html .= "&lt;td&gt;" . $row['address'] . "&lt;/td&gt;";
  
  //NOW PRINT WHAT TABLE ITS FROM
  if (table == "table1")
      $html .= "&lt;td&gt;Its from Table 1&lt;/td&gt;";
  else if (table == "table2")
      $html .= "&lt;td&gt;Its From Table 2&lt;/td&gt;";
  
  $html .= "&lt;/tr&gt;";
          }
  print $html;
  </code></pre>
  
  <h3>Side Notes</h3>
  
  <p>1) Please do not assume both tables contain identical information... there is an omitted column for example purposes</p>
  
  <p>2) In order to assist in not asking another question... can you please also answer:  How can I modify my original <code>$query</code> to not display the rows which have, i.e. identical <code>name</code> columns.</p>
  
  <p>3) However, the original question still stands... I must display ALL rows regardless if there is a match or not....</p>
  
  <p>Thank you in advance.</p>