27 January 2008

Deleting rows older than 30 days in MySQL

Posted by Mikhail Esteves under: LAMP; Tips .

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.



Leave a Reply

Browse

Photography

Projects

Pages

Calendar

January 2008
M T W T F S S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories

www.flickr.com