1

How can I create a MySQL event that can be run every 10 minutes and update the table based on TIMESTAMP column? I have a table like:

enter image description here

Now I need to have a My SQL event which can loop to the table and update all pending from 1 to 0 IF/WHERE Date is 10 minutes older than CURRENT_TIMESTAMP on event time.

CREATE EVENT test_event
ON SCHEDULE EVERY 10 MINUTE
STARTS CURRENT_TIMESTAMP
ENDS CURRENT_TIMESTAMP + INTERVAL 10 MINUTE
DO
UPDATE `pending` SET = 0 WHERE `Date` > CURRENT_TIMESTAMP
halfer
  • 19,824
  • 17
  • 99
  • 186
Behseini
  • 6,066
  • 23
  • 78
  • 125

1 Answers1

0

With help of a cronjob you can achieve this easily. Just create a script on backend which would run the script.

What is cronjob?

you can read more about the cronjobs works: https://www.geeksforgeeks.org/how-to-setup-cron-jobs-in-ubuntu/

sid
  • 365
  • 2
  • 11