How do I automate MySQL Update or Insert upon expire timestamp?
So let say timestamp is 2013-06-30 20:10:00
and I would like to auto update MySQL DB upon passing that date and time so today after 2013-06-03 20:10:00
.
I want to update my item, but I will not have browser open with my website, so I think so I need some kind of server trigger?? How do I do that? Many thanks
I have following Query to execute every 1 second and it doesn't work:
CREATE EVENT e_second
ON SCHEDULE
EVERY 1 SECOND
DO
UPDATE online_auctions.auction_status
SET auction_status = 'ENDED' WHERE TIMESTAMP(auction_end_date) < (select now());
Use can use for that
If you go with option 1 you need to create an event
Use
SHOW PROCESSLIST
to check if event scheduler is enabled. If it'sON
you should see a process "Daemon" by user "event_scheduler". UseSET GLOBAL event_scheduler = ON;
to enable the scheduler if it's currently not enabled. More on configuring event scheduler here.If you want to see events that you've in your schema
UPDATE Your update statement should look like
Here is SQLFiddle demo