title: MySQL query cross reference
body: <p>I'm looking for a mysql query (using php) to go through each table one at a time and only display results that are different than those in cross_check.lastmod </p>
  
  <p><strong>t_one</strong></p>
  
  <pre><code>guid | name | lastmod
   1   |  Joe | 2012-01-01 01:00:00
   2   |  Tom | 2012-01-02 01:00:00
   3   |  Sue | 2012-03-01 02:00:00
  </code></pre>
  
  <p><strong>t_two</strong></p>
  
  <pre><code>guid | pet  | lastmod
   4   | cat  | 2012-01-01 01:00:00
   5   | dog  | 2012-01-02 01:00:00
   6   | fish | 2012-03-01 02:00:00
  </code></pre>
  
  <p><strong>t_three</strong></p>
  
  <pre><code>guid | fruit   | lastmod
   7   |  orange | 2012-01-01 01:00:00
   8   |  pear   | 2012-01-02 01:00:00
   9   |  grape  | 2012-03-01 02:00:00
  </code></pre>
  
  <p><strong>cross_check</strong></p>
  
  <pre><code>guid | lastmod
     1 |  2012-01-01 01:00:00
     2 |  2012-01-02 01:00:00
     3 |  2012-01-01 02:00:00
     4 |  2012-01-01 01:00:00
     5 |  2012-01-02 01:00:00
     6 |  2012-01-01 02:00:00
     7 |  2012-01-01 01:00:00
     8 |  2012-01-02 01:00:00
     9 |  2012-01-01 02:00:00
  </code></pre>
  
  <p><strong>The query results would be:</strong></p>
  
  <pre><code>t_one =&gt; 3 | Sue   | 2012-03-01 02:00:00
  t_two =&gt; 6 | fish  | 2012-03-01 02:00:00
  t_three =&gt; 9 | grape | 2012-03-01 02:00:00
  </code></pre>
  
  <p>My code so far (needs the table cross reference)</p>
  
  <pre><code>$tables = array('t_one', 't_two', 't_three');
  
    foreach ($tables AS $table) {
  
      $query = sprintf("SELECT * FROM '%s'",
      mysql_real_escape_string($table));
  
      $result = mysql_query($query);
  
    }
  </code></pre>