title: SQL query to retrieve conversations from messages?
body: <p>I'm trying to get conversations from my private messages table with a single elegant SQL query. Here's a simplified version of my table:</p>
  
  <p><img src="https://i.imgur.com/IPJX4Em.png" alt="Sample table"></p>
  
  <p>Let's say I want to retrieve all James's conversations. The lines highlighted in green are the ones I want him to have in his inbox. In other words, I want to select the latest messages james has received, grouped by sender. I've tried the following query :</p>
  
  <pre><code>SELECT *
  FROM "messages"
  WHERE To = "James"
  ORDER BY Id DESC
  GROUP BY `From`
  </code></pre>
  
  <p>But MySQL returns me these rows :</p>
  
  <p><img src="https://i.imgur.com/nqx2rlE.png" alt="Sample table"></p>
  
  <p>So how could I fix this request ?</p>
  
  <p>Thanks !</p>
  
  <p><strong>EDIT</strong>: I Shouldn't have used "From" as a field name, I won't change it now to avoid  breaking the answers but sorry about that.</p>