KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to delete some messages from my MySQL database after 7 days. My message table rows have this format: id | message | date The date is a timestamp in the normal format; 2012-12-29 17:14:53 I was thinking that an MySQL event would be the way to go instead of a cron job. I have what I guess is a simple question to an experienced SQL person, how do I code the delete messages portion in brackets below? An example would be appreciated, Thanks. DELIMITER $$ CREATE EVENT delete_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY ON COMPLETION PRESERVE DO BEGIN DELETE messages WHERE date >= (the current date - 7 days); END; $$;
Tags (comma-separated)
Save Edits
Cancel