Delete records older dan 3 hours
DELETE FROM `my_table` WHERE `created_at` < (NOW() - INTERVAL 3 HOUR);
Delete records older then 3 days
DELETE FROM `my_table` WHERE `created_at` < (NOW() - INTERVAL 3 DAY);
Delete records older then 3 months
DELETE FROM `my_table` WHERE `created_at` < (NOW() - INTERVAL 3 MONTH);
Categorieën
MySQL