On Tue, Jun 14, 2005 at 09:54:26AM +0530, Ajay wrote:
> There are 3 tables interconnected with each other by foreign keys. On
> deleting particular item from one table should delete all items from other
> tables that was pointing to it using foreign key (Just like
> ON_DELETE_CASCADE - SQLite does not support ON_DELETE_CASCADE, so I want to
> write query to do so)
>
> Let me know is there any other solution to do so.
It's really simple. Suppose baz.foo_id references foo(foo_id)
CREATE TRIGGER on_delete_foo DELETE ON foo
BEGIN
DELETE FROM baz WHERE foo_id=OLD.foo_id;
END;
Dave Cook