MySQL CREATE TRIGGER,语法错误。我做错了什么?
DELIMITER ||
CREATE TRIGGER `monthly_insert` BEFORE INSERT ON `history_monthly`
FOR EACH ROW
BEGIN
NEW.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
END;
||
DELIMITER ;
它返回一个错误:
#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 '.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
END' at line 4
这是我第一次使用触发器,我正在尽最大努力尝试找到灵魂,但我失败了;<
DELIMITER ||
CREATE TRIGGER `monthly_insert` BEFORE INSERT ON `history_monthly`
FOR EACH ROW
BEGIN
NEW.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
END;
||
DELIMITER ;
And it returns an error:
#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 '.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
END' at line 4
It's my first time with triggers and I was doing my best to try to find soultion but I failed ;<
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在这一行中添加单词
SET
:此外,正如评论者指出的那样,
BEFORE INSERT
触发器中没有OLD
值。You need to add the word
SET
in this line:Also, as the commenter pointed out, there is no
OLD
value in aBEFORE INSERT
trigger.