CREATE EVENT update_status
ON SCHEDULE EVERY 2 SECOND
DO
UPDATE `practiceme.events` as e
set `e.status` =
CASE
WHEN CURRENT_DATE < `e.eventStart` THEN 'Upcoming'
WHEN CURRENT_DATE > `e.eventStart` THEN 'Ongoing'
WHEN CURRENT_DATE > `e.eventEnd` THEN 'Past'
ELSE `status`
END
As of now I have this which is not working as my status column in events table is not updating. This is what I have now when I run SHOW EVENTS FROM practiceme; This is my events table
eventStart is the startofdate of this event, eventEnd is the endofdate of this event.
I want to update the status column in events table when the current date is smaller than eventStart then set column status as Upcoming. If current date is more than eventStart then set column as Ongoing. If current date is more than eventEnd then set column as Past. Also check for all rows.