我在MySql dealersdealers_info中有2个表。我尝试创建触发器,该触发器从dealers删除信息后将从dealers info删除相应的行

CREATE TRIGGER del_info AFTER DELETE ON  dealers
FOR EACH ROW
BEGIN
DELETE FROM dealers_info WHERE dealer_id = OLD.dealer_id;
END;


但是我有一个错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '' at line 4

最佳答案

更改定界符以正确执行查询,

DELIMITER $$
CREATE TRIGGER del_info
AFTER DELETE ON  dealers
FOR EACH ROW
BEGIN
    DELETE FROM dealers_info WHERE dealer_id = OLD.dealer_id;
END $$
DELIMITER ;

关于mysql - MySql触发错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15152570/

10-11 05:03