在insert之前,我有下面的触发器代码,但是当我试图在终端上运行时,这给了我错误。
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 ;

发布于 2019-03-27 13:08:34
全部替换
else if使用
elseifhttps://stackoverflow.com/questions/55369631
复制相似问题