我的mysql触发代码出现语法错误。错误1064(42000):

时间:2019-03-25 05:02:17

标签: mysql triggers

我有以下触发代码,但给我错误。我无法弄清楚我的代码出了什么问题。

    DROP TRIGGER IF EXISTS `user_has_voice_queues_rt_update`;
    CREATE DEFINER=`root`@`localhost` 
    TRIGGER `user_has_voice_queues_rt_update` 
    BEFORE UPDATE ON `user_has_voice_queues_rt` 
    FOR EACH ROW begin 
    if(new.pause='0') then  
    Set new.penalty = (select max(penalty) from user_has_voice_queues_rt) + 1; 
    end if;

1 个答案:

答案 0 :(得分:0)

尝试一下:

DROP TRIGGER IF EXISTS `user_has_voice_queues_rt_update`;
DELIMITER $$

CREATE DEFINER=`root`@`localhost` 
TRIGGER `user_has_voice_queues_rt_update` 
BEFORE UPDATE ON `user_has_voice_queues_rt` 
FOR EACH ROW begin 
if(new.pause='0') then  
Set new.penalty = (select max(penalty) from user_has_voice_queues_rt) + 1; 
end if;

END $$
DELIMITER ;