Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 个表 A(id, Name), B(id, fid, Name) 其中A.id = B.fid,我的要求是每当 A 中的行删除时我想删除 B 中的行
这是我尝试过的查询,但它在 B 附近给了我错误。
Create Trigger Delete_B_trigger After Delete on A For each row Begin Delete from B where fid = id; End
DELETE 命令需要一个 FROM。
要访问触发表中的值,您必须使用OLD 或 NEW别名。
CREATE TRIGGER Delete_B_trigger AFTER DELETE ON A FOR EACH ROW BEGIN DELETE FROM B WHERE fid = OLD.id; END