title: How can I use order by and group by in sql?
body: <p>Here is my problem:
  I have these tables:</p>
  
  <pre><code>felado  fogado  fehide  fohide  datum   olvasott    tartalom
  </code></pre>
  
  <p>felado = sender, fogado = receiver, </p>
  
  <p>I would like to get all where felado or fogado is me and group the lines. So If there are the next lines</p>
  
  <pre><code>sender 1 receiver 2 id 1
  sender 1 receiver 2 id 2
  sender 1 receiver 2 id 3
  sender 2 receiver 1 id 4
  </code></pre>
  
  <p>I only would like to get one from these lines, the last by ID. </p>
  
  <p>Now I'm trying like this:</p>
  
  <pre><code>SELECT * 
  FROM belso_levelezes 
  WHERE (felado="'.$_SESSION["userData"]["id"].'"
     or fogado="'.$_SESSION["userData"]["id"].'" )
  ORDER BY id DESC 
  GROUP BY felado, fogado
  </code></pre>
  
  <p>It gaves me only one from all, but not the last records. How can I get the last records from each group? 
  I want to get only this:</p>
  
  <pre><code>sender 2 receiver 1 id 4
  </code></pre>