MySQL Event Scheduling for Specific Daily Time
Question: How can I schedule an event to update a MySQL database field to "0" every day at 1 pm using the MySQL Event Scheduler?
Answer: To achieve this, you can utilize the MySQL Event Scheduler with the following query:
CREATE EVENT event_name ON SCHEDULE EVERY 1 DAY STARTS CURRENT_TIMESTAMP + INTERVAL 13 HOUR DO UPDATE `ndic`.`students` SET `status` = '0';
Explanation:
Alternative to TIMESTAMP:
You can use CURRENT_DATE and CURRENT_TIME instead of TIMESTAMP to specify the date and time components separately. For example, to start the event at 1 pm on a specific date, you can use the following:
STARTS (CURRENT_DATE + INTERVAL 1 DAY + INTERVAL 13 HOUR)
The above is the detailed content of How to Schedule a Daily MySQL Event to Update a Database Field at 1 PM?. For more information, please follow other related articles on the PHP Chinese website!