title: SQL query for messages database
body: <p>I'm trying to make messaging system similar to facebook. I know how to show all messages between 2 users, but I don't know how to make this </p>
  
  <p><img src="https://i.stack.imgur.com/6aYWi.png" alt="enter image description here"></p>
  
  <p>This is my database</p>
  
  <p><img src="https://i.stack.imgur.com/vGUtt.png" alt="enter image description here"></p>