我有这段代码:
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更新用户,但我只希望从星期一到星期五更新用户。
答案 0 :(得分:2)
基于此处的逻辑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;