I've 2 tables A(id, Name), B(id, fid, Name) where A.id = B.fid, My requirement is I want to delete Row in B whenever row in A deletes
Here is query which i tried but it gives me Error near B..
Create Trigger Delete_B_trigger After Delete on A For each row Begin Delete from B where fid = id; End
The DELETE command requires a FROM.
To access values in the triggering table, you have to use the OLD or NEW aliases.
CREATE TRIGGER Delete_B_trigger
AFTER DELETE ON A
FOR EACH ROW
BEGIN
DELETE FROM B WHERE fid = OLD.id;
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With