title: How to compare two timestamps in MySql?
body: <p>The timestamp field is a <code>DATETIME</code> column in a format like <code>2012-03-19 00:23:14</code>. How can I compare two rows of timestamps and find the larger one?  The query below that I am using isn't working.</p>
  
  <pre><code>UPDATE report 1 status = 'time is larger' WHERE EXISTS 
    (SELECT ip_src, layer4_sport, timestamp FROM  
        (SELECT ip_src, layer4_sport, timestamp from report 1) AS tmpb  
     WHERE  report 1.layer4_sport = tmpb.layer4_sport 
     AND report 1.ip_src = tmpb.ip_src  
     AND  report 1.timestamp &gt; tmpb.timestamp 
     GROUP BY ip_src, layer4_sport,  timestamp HAVING COUNT(*) = 2)
  </code></pre>