1
 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 

这是我第一次使用触发器,我正在尽力寻找灵魂,但我失败了;<

4

1 回答 1

1

您需要SET在此行中添加单词:

SET NEW.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);

此外,正如评论者指出的那样,触发器没有OLD价值。BEFORE INSERT

于 2011-02-09T18:46:15.667 回答