本文介绍了如何在mysql事件调度程序中运行两个更新查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Mysql 事件调度器是这样的:
Mysql event scheduler is like this :
CREATE EVENT update_status
ON SCHEDULE EVERY 2 MINUTE
DO
BEGIN
UPDATE customer_group
SET is_status = 0
WHERE CURRENT_TIMESTAMP BETWEEN start_date AND end_date;
UPDATE customer_group
SET is_status = 1
WHERE CURRENT_TIMESTAMP NOT BETWEEN start_date AND end_date;
END
当我运行脚本时,存在这样的错误:
When I run the script, there is exist error like this :
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
有什么解决方案可以解决我的问题?
Any solution to solve my problem?
非常感谢
推荐答案
试试这个:
DELIMITER $$
CREATE EVENT update_status
ON SCHEDULE
EVERY 2 MINUTE
DO
BEGIN
UPDATE
customer_group
SET
is_status = 0
WHERE
CURRENT_TIMESTAMP BETWEEN start_date AND end_date;
UPDATE
customer_group
SET
is_status = 1
WHERE
CURRENT_TIMESTAMP NOT BETWEEN start_date AND end_date;
END $$
DELIMITER ;
这篇关于如何在mysql事件调度程序中运行两个更新查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!