0

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 likeenter image description here

But when I run this update query normally, it works perfectly. Please help.

Reference: http://www.sitepoint.com/how-to-create-mysql-events/

1 Answer 1

1

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 ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.