我在插入之前在触发器代码上有以下内容,但这在尝试在终端上运行时给了我错误。
DROP TRIGGER IF EXISTS `user_has_voice_queues_rt_Insert`;
DELIMITER $$
CREATE TRIGGER `user_has_voice_queues_rt_Insert` BEFORE INSERT ON `user_has_voice_queues_rt`
FOR EACH ROW
if(new.penalty=0) THEN
Set new.guard_name = (select IFNULL(max(penalty),'0') as max from user_has_voice_queues_rt where penalty between 0 and 6999) + 1;
Else If(new.penalty=1) THEN
Set new.guard_name = (select IFNULL(max(penalty), '7000') as max from user_has_voice_queues_rt where penalty between 7000 and 8999) + 1;
Else IF(new.penalty=2) THEN
Set new.guard_name = (select IFNULL(max(penalty),'9000') as max from user_has_voice_queues_rt where penalty between 9000 and 9500) + 1;
Else IF(new.penalty=3) THEN
Set new.guard_name = (select IFNULL(max(penalty),'9500') as max from user_has_voice_queues_rt where penalty between 9501 and 9999) + 1;
END IF
$$
DELIMITER ;
最佳答案
全部替换
else if
与
elseif
关于mysql - MySQL触发器插入后插入错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55369631/