title: Private chat system MYSQL query ORDERBY and GROUPBY
body: <p>I am creating private message system in php/mysql.</p>
  
  <p>I created message tables: </p>
  
  <pre><code>messages(message_id|sender_id|receiver_id|message_text|created_time)
  </code></pre>
  
  <p>Here is data in table</p>
  
  <pre><code>message_id|sender_id||receiver_id|message_text|   created_time
     1         101          102       Message A    2012-06-07 08:07:18
     2         101          102       Message B    2012-06-07 08:10:20
     3         103          102       Message C    2012-06-07 08:12:43
  </code></pre>
  
  <p>The output I want is:</p>
  
  <pre><code>     sender_id|message_text |   created_time
         101      Message B     2012-06-07 08:10:20
         103      Message C     2012-06-07 08:12:43
  </code></pre>
  
  <p>Something like:</p>
  
  <pre><code>SELECT sender_id,message_text,created_time from messages
  WHERE receiver_id='102'
  GROUP BY sender_id
  ORDERBY BY created_time
  </code></pre>
  
  <p>I want to show the last message of any user.</p>