MySQL说:#1064 - 你的SQL语法有错误;

时间:2018-05-07 06:35:42

标签: mysql sql events

错误:

  

查看与您的MariaDB服务器版本对应的手册   在第5行“END”附近使用的正确语法

CREATE DEFINER=`root`@`localhost` EVENT `start_game` ON SCHEDULE EVERY 3 MINUTE STARTS '2018-05-05 05:50:07' ON COMPLETION PRESERVE DISABLE DO BEGIN
set @game_id = (select id FROM tbl_game where game_status=0 ORDER BY id ASC LIMIT 1);

update tbl_game set game_status = 1 where id = @game_id;
END

1 个答案:

答案 0 :(得分:1)

在批次之前和之后使用DELIMITER

DELIMITER $$
CREATE DEFINER=root@localhost EVENT start_game ON SCHEDULE EVERY 3 MINUTE STARTS '2018-05-05 05:50:07' ON COMPLETION PRESERVE DISABLE DO BEGIN set @game_id = (select id FROM tbl_game where game_status=0 ORDER BY id ASC LIMIT 1);

update tbl_game set game_status = 1 where id = @game_id; 
END $$
DELIMITER ;