title: How to select users in message table in MySQL and order them by date?
body: <p>I am building a messaging module in MySQL and PHP. I have a table in which I am saving the messages.</p>
  
  <p>The table for messages has the following columns:</p>
  
  <pre><code>Index | from | to | date | body 
  </code></pre>
  
  <p>Now I want to select the users who sent or received text from a specific user and order that by date.</p>
  
  <p>If I am user 2, table:</p>
  
  <pre><code>Id | from | to | date                | body
   1 | user1 | user2 | 2018-06-18 12:51:19 | Hi
   2 | user2 | user1 | 2018-06-18 12:55:19 | Hello
  
   4 | user3 | user2 | 2018-06-18 12:55:19 | Hi
   5 | user2 | user3 | 2018-06-18 12:56:19 | Hello
   6 | user3 | user2 | 2018-06-19 01:55:19 | bolo
   7 | user2 | user3 | 2018-06-19 02:56:19 | Kya
  </code></pre>
  
  <p>If I am user 2, desired data:</p>
  
  <pre><code>  user3 | 2018-06-19 02:56:19
    user1 | 2018-06-18 12:55:19
  </code></pre>