Dear amazing programmers,
I am trying to create trigger in my application database to delete rows in a table based on multiple condition and deletion in another table, and i could use some help here.
Here is my code for the trigger
CREATE TRIGGER RemoveAccountReports
AFTER DELETE ON Accounts
FOR EACH ROW
WHEN Reports.Parent_Type = ACCOUNT
BEGIN
DELETE FROM Reports
WHERE Parent_ID = OLD.Account_ID;
END;
I need to delete from Reports table with every deletion in Accounts table where Reports.Parent_ID = Accounts.Account_ID.
But only if Reports.Parent_type = "ACCOUNT"
How can i achieve that ?
thanks in advance.