title: Delete N number of old records from table in mysql
body: <p>I have a <strong>LoginTime</strong> table like this:</p>
  
  <pre><code>id | user_id | datetime
  1  |   1     | 2011-01-19 18:51:01
  2  |   1     | 2011-01-19 18:51:02  
  3  |   1     | 2011-01-19 18:51:03  
  4  |   1     | 2011-01-19 18:51:04  
  5  |   1     | 2011-01-19 18:51:05  
  6  |   1     | 2011-01-19 18:51:06  
  7  |   1     | 2011-01-19 18:51:07  
  8  |   1     | 2011-01-19 18:51:08  
  9  |   1     | 2011-01-19 18:51:09  
  10 |   2     | 2011-01-19 18:51:10  
  </code></pre>
  
  <p>I want to keep only 5 latest(by 'datetime' column) records and delete all previous records where <code>user_id=1</code></p>
  
  <p>Is it possible to achieve this with one mysql query ?</p>