DELETE FROM `tablename` WHERE timestampColumn < NOW() – INTERVAL 7 DAY ORDER BY `tablename`.`timestampColumn` DESC
If you have a numeric timestamp then you’ll need to wrap the code in a function like this:
DELETE FROM `tablename` WHERE timestampColumn < UNIX_TIMESTAMP(NOW() – INTERVAL 1 YEAR) ORDER BY `tablename`.`timestampColumn` DESC
Leave a Reply
You must be logged in to post a comment.