title: Why doesn't my content field match my MAX(id) field in MySQL?
body: <p>I'm trying to get a subset of data based on the latest id and dates.  It seems that when selecting other fields in the table they are not in sync with the max id and dates returned.</p>
  
  <p>Any idea how I can fix this?</p>
  
  <p>MySQL:</p>
  
  <pre><code>SELECT MAX(m.id) as id, m.sender_id, m.receiver_id, MAX(m.date) as date, m.content, l.username, p.gender 
  FROM  messages m 
  LEFT JOIN login_users l on l.user_id = m.sender_id 
  LEFT JOIN profiles p ON p.user_id = l.user_id 
  WHERE m.receiver_id=3
  GROUP BY m.sender_id ORDER BY date DESC LIMIT 0, 7
  </code></pre>
  
  <p>The data for content isn't the correct one. It seems to be returning random content and not the content that is tied to the row for max id and max date.</p>
  
  <p>Do I need to do some sort of sub select to fix this?</p>