错误AFTER DELETE触发器

时间:2016-11-21 14:39:21

标签: mysql triggers mysql-error-1064

我正在编写新的触发器,我确定它没问题,但是当我尝试 SQL命令时,我收到此错误:

CREATE TRIGGER tax_delete
   AFTER DELETE ON cashflow FOR EACH ROW
   BEGIN
      DELETE FROM tax_cashflow
      WHERE tax_cashflow.id_user = OLD.id_user
      AND tax_cashflow.id_orig = OLD.id_orig
      AND tax_cashflow.id_orig_user = OLD.id_orig_user;
    END;
  

1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法   靠近''在第7行

任何人都可以帮我理解错误在哪里? 感谢

1 个答案:

答案 0 :(得分:0)

试试这个

DELIMITER //    

create TRIGGER tax_delete
AFTER DELETE ON cashflow FOR EACH ROW
BEGIN
DELETE FROM tax_cashflow
WHERE tax_cashflow.id_user = OLD.id_user
AND tax_cashflow.id_orig = OLD.id_orig
AND tax_cashflow.id_orig_user = OLD.id_orig_user;

END; //

DELIMITER ;