我想要一个触发器,在user_briefcases
user_briefcases_sold
中的行
这两个表都有briefcase_id
和user_id
我不知道为什么这不起作用:
CREATE TRIGGER delete_user_briefcase_when_sold
DELIMITER $$
AFTER INSERT ON user_briefcases_sold FOR EACH ROW BEGIN
DELETE FROM user_briefcases WHERE briefcase_id = NEW.briefcase_id && user_id = NEW.user_id;
END;
$$ DELIMITER ;
答案 0 :(得分:0)
您有语法错误
试试这个
DELIMITER $$
CREATE
TRIGGER delete_user_briefcase_when_sold AFTER INSERT
ON user_briefcases_sold
FOR EACH ROW BEGIN
DELETE FROM user_briefcases WHERE briefcase_id = NEW.briefcase_id AND user_id = NEW.user_id;
END$$
DELIMITER ;