title: MySQL get a conversation between two users
body: <p>I have a SQL table named private_messages with fields (id,from,to,message,stamp).
  the stamp field corresponds to the date of the message</p>
  
  <p>So what query do i need for:</p>
  
  <p>1) get a conversation between two users (ordered by date)?</p>
  
  <p>I have tried the query </p>
  
  <pre><code>(SELECT * FROM private_messages WHERE from=$my_id AND to=$other_id) 
  UNION 
  (SELECT * FROM private_messages WHERE from=$other_id AND to=$my_id) 
  ORDER BY stamp
  ;
  </code></pre>
  
  <p>but doesn't work...</p>
  
  <p>2) get the last messages beetween me and other users, each one with a different user, ordered by date (to construct a inbox like in faceebook for example)?</p>