title: Generate a table from the data of another table
body: <p>What I'm trying to do is that I have a table called messages. It has 5 fields ID, SENDER, RECIPIENT, MESSAGE and TIMESTAMP. Each user gets an id when he uses this app. Each message that he sends using this app gets stored in this table with the id of the recipient. </p>
  
  <p>Now what I want is to be able to list the most recent message of each conversation and then list each conversation in order of the recency of their last message. Lets call this table CONVERSATIONS. </p>
  
  <p>Each conversation between two users XX and YY is defined as a table generated by </p>
  
  <pre><code>SELECT * FROM MESSAGES WHERE SENDER=XX and RECIPIENT=YY ORDER BY TIMESTAMP
  </code></pre>
  
  <p>In CONVERSATIONS table we only want the most recent message of each of the conversations in the MESSAGES table. </p>
  
  <p>I don't want to use PHP and was looking for a solution only using MySQL. Thank you. </p>