title: MySQL: How to get the last message of conversation between two users?
body: <p>This is what my database looks like</p>
  
  <pre><code>id | Sender  |  Receiver |  Send_Date   | Message
  =========================================================
  1  | user A  |   user B  |  1463311906 | hello
  2  | user B  |   user A  |  1463311906 | hi
  3  | user A  |   user B  |  1463311906 | howdy
  4  | user C  |   user A  |  1463311906 | great
  5  | user A  |   user C  |  1463311906 | good
  </code></pre>
  
  <p>I want to select the last message of conversation between two different users. For example, a list where it shows the last message between user A and B, last message between user B and C and so on, where user B or C is not defined. The user A is the user using the application and he wants to see last message of his conversation with all other users (B, C etc), either be the last message is his or from the opposite user.</p>
  
  <p>So far I've tried with the below query, but this shows both the last messages sent by user A and User B in a conversation between user A and user B, it's the same with User A and C, when I only want the last messages sent or received between these users. </p>
  
  <pre><code>SELECT send_date
       , message
       , reciever
       , sender 
    FROM 
       ( SELECT * 
           FROM messages 
          WHERE sender = user A or reciever = user A
       ) AS newmesssages 
   GROUP 
      BY sender
       , reciever 
   ORDER 
      BY send_date DESC
  </code></pre>