title: Mysql delete 5th element of a table
body: <p>I have a table:</p>
  
  <pre><code> ID Friend
  John    Rita
  John    Jack
  Jack    Rita
  Rita    John
  John    Peter
  John    Owen
  John    Eric
  John    Louis
  </code></pre>
  
  <p>I want to write a query where I delete all <code>ID</code>'s after the 5th element. In other words I want to keep for each <code>ID</code> maximum 5 <code>friends</code>. </p>
  
  <p>I have tried with a <code>group by</code> or something like that, but I don't now exactly how I have to do the delete.</p>
  
  <p>The result must be:</p>
  
  <pre><code>  ID    Friend
  John    Rita
  John    Jack
  Jack    Rita
  Rita    John
  John    Peter
  John    Owen
  John    Eric
  </code></pre>