用于删除行的SQLite触发器表达式

时间:2013-03-04 08:00:14

标签: android sqlite triggers

我有2个表A(id,Name),B(id,fid,Name),其中 A.id = B.fid ,我的要求是我想删除B中的Row A中的行删除

这是我试过的查询,但它给了我B附近的错误..

Create Trigger Delete_B_trigger After Delete on A For each row Begin Delete from B where fid = id; End

1 个答案:

答案 0 :(得分:15)

DELETE命令requires一个FROM。

要访问触发表中的值,您必须使用OLD or NEW别名。

CREATE TRIGGER Delete_B_trigger
AFTER DELETE ON A
FOR EACH ROW
BEGIN
    DELETE FROM B WHERE fid = OLD.id;
END