Deleting rows older than 30 days in MySQL
If you want to delete rows older than xx dates using MySQL, here is a simple way of doing so:
DELETE FROM mytable WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY);
You could also use INTERVAL 1 MONTH.
If you want to delete rows older than xx dates using MySQL, here is a simple way of doing so:
DELETE FROM mytable WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY);
You could also use INTERVAL 1 MONTH.
Hey Thanks! This helped me clear out 135,000 records in about a minute.
Thanks, this made my night.
Robbie, you work for Pentagon? xD Btw: nice one with MySQL command :)
beautiful work – scheduled this with my wordpress install.