title: Get only last chat message of whole friend list of a user from database
body: <p>I need a query in sql which can get me the details of the last message of all the friends of the user .The fields in my sql database are :</p>
  
  <pre><code>message_id      (primary key)
  sender          (username of the sender)
  message_content (text of the message)
  user_id         (user id of the app user)
  friend_id       (user id of the app user's friends)
  message_time    (time of the message receive on server)
  receiver        (user id of the receiver)
  </code></pre>
  
  <p><strong>Edit</strong> : So far I think my closest try was </p>
  
  <pre><code>Select * from user_chat_messages where message_id on (Select distinct message_id from user_chat_messages order by message_time limit 1,0);
  </code></pre>
  
  <p>Rest all other queries that I tried were a total failure  :(</p>