title: Mysql: Update field of most latest record
body: <p>I'm trying to update the latest record where name is <code>John</code> (<code>John</code> has multiple records but different ID) but I seem to be in a bind. What's wrong with my query?</p>
  
  <pre><code>UPDATE messages_tbl SET is_unread=1
  WHERE ReceiveTime = (SELECT MAX(ReceiveTime) FROM messages_tbl WHERE name='John')
  </code></pre>
  
  <p>Is there a better way to do something like this?</p>