DELETE FROM `gangs_actions`
WHERE `gangs_actions_id` < (
SELECT `gangs_actions_id` FROM `gangs_actions`
ORDER BY `gangs_actions_id` DESC
LIMIT 5,1
)
DELETE FROM gangs_actions
WHERE gangs_actions_id < (SELECT MAX(gangs_actions_id) - 5 FROM (SELECT * FROM gangs_actions) tmp)
DELETE FROM gangs_actions
WHERE gangs_actions_id <= (
SELECT gangs_actions_id FROM (SELECT * FROM gangs_actions) as tmp
ORDER BY gangs_actions_id DESC
LIMIT 5,1
)
DELETE FROM `gangs_actions`
WHERE `gangs_actions_id` IN (
SELECT `gangs_actions_id` FROM `gangs_actions`
ORDER BY `gangs_actions_id` DESC
LIMIT 5
)