Is there an MySQL query which would delete all values from a table, except the latest 20 entries (ordered by id
)?
So let's say I have a table notifications
, where 1000 notifications reside and I want to keep only latest 20.
If SQL is not enough for this, using php
is optional.
I have a few ideas how to do this, but I don't really consider them efficient.