title: Get highest ids in by an inner join and max id
body: <p>I got two tables, conversations and messages,
  What I'd like to do is to make a inner join from conversations to messages. </p>
  
  <p>Here is my query:</p>
  
  <pre><code>    SELECT 
      messages.msg,
      messages.`read`,
      conversations.userid,
      conversations.contactid
  
      FROM conversations 
          INNER JOIN messages ON 
          conversations.id = messages.convId
      WHERE conversations.id IN(443,444)
  </code></pre>
  
  <p>Now everything works as it should, but a last thing is that in the inner join where i use</p>
  
  <pre><code>conversations.id = messages.convId
  </code></pre>
  
  <p>I would like to get the highest ids only, like:</p>
  
  <pre><code> AND MAX(messages.id)
  </code></pre>
  
  <p>But that doesn't work  </p>
  
  <p><strong>EDIT:</strong>
  I tried once to use:</p>
  
  <pre><code>LEFT JOIN messages 
      ON conversations.id = messages.convId 
          AND messages.id = MAX(messages.id) 
  </code></pre>
  
  <p>But i got an error saying: Invalid use of group function.</p>