如何在特定时间创建周一至周五的 MYSQL 计划活动?
How to create a MYSQL scheduled event from Monday to Friday at specific time?
我有这个代码:
CREATE EVENT event1
ON SCHEDULE EVERY 1 DAY
STARTS '2015-11-20 23:00:00'
DO
UPDATE users SET username='verde' WHERE id=1;
求助,我的代码每天在 23:00 更新用户,但我只想在周一到周五更新用户。
基于此处找到的逻辑http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayofweek
CREATE EVENT event1
ON SCHEDULE EVERY 1 DAY
STARTS '2015-11-20 23:00:00'
DO
IF DAYOFWEEK(curdate()) BETWEEN 2 AND 6 THEN
UPDATE users SET username='verde' WHERE id=1;
END IF;
我有这个代码:
CREATE EVENT event1
ON SCHEDULE EVERY 1 DAY
STARTS '2015-11-20 23:00:00'
DO
UPDATE users SET username='verde' WHERE id=1;
求助,我的代码每天在 23:00 更新用户,但我只想在周一到周五更新用户。
基于此处找到的逻辑http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayofweek
CREATE EVENT event1
ON SCHEDULE EVERY 1 DAY
STARTS '2015-11-20 23:00:00'
DO
IF DAYOFWEEK(curdate()) BETWEEN 2 AND 6 THEN
UPDATE users SET username='verde' WHERE id=1;
END IF;