title: Get Last Message from Each Conversation sql
body: <p>I have a sql table which include conversation between users. I need to retrieve the last message from every conversation in order to preview it. </p>
  
  <pre><code>id | sender   | receiver     | message      | date
   1 |        1 |            2 | Hello        | 2015-12-08 20:00
   2 |        2 |            1 | Hey          | 2015-12-08 20:10
   3 |        2 |            1 | You there?   | 2015-12-08 21:00
   4 |        1 |            3 | Yes          | 2015-12-08 21:15
   5 |        4 |            1 | Hey buddy    | 2015-12-08 22:00
  </code></pre>
  
  <p>I know many similar question on site but i couldn't fix this.</p>
  
  <p>I tried this code but not working properly: </p>
  
  <pre><code>SELECT *
  FROM   messages
  WHERE  receiver = '{$id}'
  GROUP BY sender
  ORDER BY id DESC
  LIMIT 10;
  </code></pre>