title: MySQL DELETE all but latest X records
body: <p>I have a script that runs every hour on my php site. In that script I would like some kind of MySQL query to delete every record from a table but say the latest 50. </p>
  
  <p>How would I do something like that? </p>
  
  <pre><code>// pseudo code: like this?
  DELETE from chat WHERE id = max (ID - 50) 
  </code></pre>