我正在使用 Aurora Serverless MySQL 5.6 创建以下触发器,该触发器将在将数据插入另一个表但收到语法错误时更新一个表,特别是在 Delimiter 关键字周围。
DELIMITER $$
CREATE TRIGGER Create_Media_Like_Trigger AFTER INSERT ON MediaLike
FOR EACH ROW
BEGIN
IF NEW.likeType = 'LIKE' THEN
UPDATE Media
SET Media.numLikes = Media.numLikes + 1
WHERE Media.mediaId = NEW.mediaId;
ELSEIF NEW.likeType = 'DISLIKE' THEN
UPDATE Media
SET Media.numLikes = Media.numLikes - 1
WHERE Media.mediaId = NEW.mediaId;
ENDIF;
END $$
DELIMITER ;
就像我上面说的,我在 附近收到语法错误DELIMITER
,这个问题是 AWS 特有的,我该如何解决?
更新错误消息:
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 'DELIMITER $$ CREATE TRIGGER Create_Media_Like_Trigger
AFTER INSERT ON MediaLike ' at line 1
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 'ELSEIF NEW.likeType = 'DISLIKE' THEN UPDATE Media SET
Media.numLikes = Media.num' at line 1
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 'END $$' at line 1