I have a script that runs every hour on my php site. In that script I would like some kind of MySQL query to delete every record from a table but say the latest 50.
How would I do something like that?
// pseudo code: like this?
DELETE from chat WHERE id = max (ID - 50)
You could try using NOT IN:
EDIT for MySQL:
This is for SQL-Server:
Assuming higher values of
idare always newer.