title: sql query help? Sql newbie question
body: <p>I keep getting this statement "Invalid use of group function"</p>
  
  <p>for this query </p>
  
  <pre><code> mysql_query("UPDATE users SET users.lastmessage = MAX(messages.id) WHERE users.name ='tom'") 
  or die(mysql_error());  
  </code></pre>
  
  <p>What I'm trying to do is take the lastmessage field in the users table and update it to be the largest id in the messages table where the name = tom</p>
  
  <p>What did I do incorrectly   </p>