I have a condition, where in Audit logs, if the records exceeds 100k, then delete the previous old records, I dont want to delete all the 100k records, but want to delete only old records, I want to maintain the latest 100k records.
Below is a query i have tried, please anyone help me, how to prepare the query.
DELETE FROM audit_logs where
id not in (SELECT id from audit_logs order by ID DESC LIMIT 100000);