DELIMITER $$
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
TRIGGER `ir_db1407`.`after_update_ind_user` AFTER UPDATE
ON `ir_db1407`.`ind_user`
FOR EACH ROW BEGIN
SET @user_id=OLD.id
IF (NEW.STATUS = '2' OR NEW.STATUS ='3')
THEN
DELETE FROM ind_user_events WHERE user_id = @user_id;
DELETE FROM ind_user_mobile WHERE user_id = @user_id;
END IF;
END$$
DELIMITER;
错误代码:1064 您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'if(new.status ='2'或new.status ='3')附近使用正确的语法 然后 从第7行的ind_user_events中删除
答案 0 :(得分:2)
更改
SET @user_id=OLD.id
到
SET @user_id=OLD.id;
^
你实际上甚至不需要这个变量。所以放弃那条线并尝试
...
IF (NEW.STATUS = '2' OR NEW.STATUS ='3') THEN
DELETE FROM ind_user_events WHERE user_id = OLD.id;
DELETE FROM ind_user_mobile WHERE user_id = OLD.id;
END IF;
...