I am trying to create one MySQL event which updates the table at every midnight. My query is like this:
CREATE EVENT postdetails_change_status
ON SCHEDULE EVERY 1 DAY STARTS '2014-04-21 00:00:00'
DO BEGIN
UPDATE postdetails SET status = 'completed' WHERE DeleteDate < CURDATE();
END;
This gives me error like
But when I run this update query normally, it works perfectly. Please help.
Reference: http://www.sitepoint.com/how-to-create-mysql-events/
Your script is correct but just change delimiter before script execution. try below:
delimiter |
CREATE EVENT postdetails_change_status
ON SCHEDULE EVERY 1 DAY STARTS '2014-04-21 00:00:00'
DO BEGIN
UPDATE postdetails SET status = 'completed' WHERE DeleteDate < CURDATE();
END |
delimiter ;