title: SQL query: Delete all records from the table except latest N?
body: <p>Is it possible to build a single mysql query (without variables) to remove all records from the table, except latest N (sorted by id desc)?</p>
  
  <p>Something like this, only it doesn't work :)</p>
  
  <pre><code>delete from table order by id ASC limit ((select count(*) from table ) - N)
  </code></pre>
  
  <p>Thanks.</p>