I need a single query. Delete all rows from the table except the top N rows. The table has only one column. Like,
Delete
|friends_name| ==============
If you don't have an id field, i suppose you use an alphabetic order.
DELETE FROM friends WHERE friends_name NOT IN ( SELECT * FROM ( SELECT friends_name FROM friends ORDER BY friends_name ASC LIMIT 10) r )
You delete all rows exept the 10 firsts (alphabetic order)