以下查询失败:
CREATE EVENT `UNUSED`
ON SCHEDULE EVERY 1 HOUR
STARTS '2016-06-14 11:00:00.000000' ENDS '2016-06-30 01:00:00.000000'
ON COMPLETION NOT PRESERVE ENABLE DO
UPDATE quotation_details SET status='UNUSED' WHERE updatedTime <= DATE_SUB(NOW(), INTERVAL 10 DAYS) ;
MySQL说:#1064 - 你的SQL语法有错误;检查与您的MariaDB服务器版本对应的手册,以便在第1行“DAYS”附近使用正确的语法
答案 0 :(得分:1)
将DAYS
更改为DAY
,如下所示;)
CREATE EVENT `UNUSED`
ON SCHEDULE EVERY 1 HOUR
STARTS '2016-06-14 11:00:00.000000' ENDS '2016-06-30 01:00:00.000000'
ON COMPLETION NOT PRESERVE ENABLE DO
UPDATE quotation_details SET status='UNUSED' WHERE updatedTime <= DATE_SUB(NOW(), INTERVAL 10 DAY) ;
请参阅DATE_SUB
函数参考here。