title: mysql - query for thread list of messages with specific conditions
body: <p>I have three tables: user, request and message. I would like to get something like the thread list that android/ios message app shows when launched.</p>
  
  <p><strong>User</strong></p>
  
  <pre>
  id  username
  1   a
  2   b
  3   c
  </pre>
  
  <p><strong>Request</strong></p>
  
  <pre>
  id
  1
  2
  3
  </pre>
  
  <p><strong>Message</strong></p>
  
  <pre>Id  request_id     sender_id   receiver_id message timestamp
  1   1       1       2       asd 2013-06-10 06:45
  2   1       1       3       sdf 2013-06-10 06:42
  3   2       1       1       dfg 2013-06-10 06:41
  4   2       1       2       fgh 2013-06-11 06:40
  5   2       1       2       ghj 2013-06-12 07:45
  6   2       2       1       jkl 2013-06-10 06:45
  7   3       3       1       zxc 2013-06-10 03:45
  8   3       3       1       xcv 2013-06-10 05:45
  </pre>
  
  <p>What I would like to get is something like this:</p>
  
  <p><strong>Thread</strong></p>
  
  <pre>
  request_id  sender_name receiver_name   last_message    last_timestamp
  1       a       b       asd     2013-06-10 06:45
  1       a       c       sdf     2013-06-10 06:42
  2       a       b       ghj     2013-06-12 07:45
  2       a       a       dfg     2013-06-10 06:41
  3       c       a       xcv     2013-06-10 05:45
  </pre>
  
  <p>Here, request_id + sender_id + receiver_id is unique for each row and last_message, last_timestamp shows the latest entry from the message table. The order will be last_timestamp descending. How do I get this table?</p>