I'm having a tough time finding a query to delete a specific number of rows in a table. My goal is to keep the number of rows in a table to a specific number. For example, I don't want to exceed 1 million rows. Isn't there a way to add a trigger on insert that looks at the row count and then deletes the number of rows that exceeds 1 million? Can someone please point me in the right direction?
I tried:
delete from `table` where `id` not in
(select `id` from `table` order by `id` desc limit 20)
But, I get error code 1235, this version of mysql doesn't yet support 'limit & in/all/any/some subquery'.
Any help is much appreciated.