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
这是我第一次使用触发器,我正尽力寻找灵魂,但我失败了;<
答案 0 :(得分:1)
您需要在此行中添加单词SET
:
SET NEW.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
此外,正如评论者指出的那样,OLD
触发器中没有BEFORE INSERT
值。