title: MySQL GROUP BY/ORDER BY problem
body: <p>I have an MySQL query like this:</p>
  
  <pre><code>   SELECT
           MAX(messages.ID) as maxID,
           messages.from,
           messages.read,
                 users.userName
        FROM
           messages
        LEFT OUTER JOIN
           users
                ON
                users.ID = messages.from
        WHERE
         messages.to = ?
        GROUP BY
         messages.from
        ORDER BY
         maxID DESC
  </code></pre>
  
  <p>While this works fine and the messages are group by the user who sent them in DESCENDING order, I now have a problem when I want to ORDER BY the messages.read row. My code is as follows: </p>
  
  <pre><code>   SELECT
           MAX(messages.ID) as maxID,
           messages.from,
           messages.read,
                 users.userName
        FROM
           messages
        LEFT OUTER JOIN
           users
                ON
                users.ID = messages.from
        WHERE
         messages.to = ?
        GROUP BY
         messages.from
        ORDER BY
               messages.read ASC,
         maxID DESC
  </code></pre>
  
  <p>Now, messages.read returns the value of the row of the first message that the user send. But I need the value of the newest (highest ID) that the user send.
  I know that GROUP BY groups by the first in the table, so how can I get around doing this?</p>
  
  <p>Thank you very much in advance,
  Fischer </p>