title: Mysql order by left join date
body: <p>I have two tables, users and sessions. Each user can have multiple sessions. I want to get user name and the date of his most recent session. But I need to do this in such a way as to be able to return the array sorted by date of last session. Also, some of the users may not have sessions so the left join will return nothing for date. </p>
  
  <pre><code>SELECT u.name, max(s.sdate) FROM users u
  LEFT JOIN sessions s ON s.uid=u.id
  ORDER BY s.sdate
  LIMIT 25,25
  </code></pre>
  
  <p>Clearly this won't work but I'd like something simple. Something similar? Note that I also need to specify which set of rows to return because of pagination. This would be page 2. I did see similar posts but they were overly complex for my use. </p>
  
  <p>I have kept this simplified to keep it easy to understand. </p>