0

I have an Two table, main table is "Invoice" and sub table is "Invoice_split". Before update on the "Invoice" table I want to delete the related data on the sub table "Invoice_split" for that I have written the below query But it's not working.

"DELIMITER $$
CREATE TRIGGER before_invoice_update 
BEFORE UPDATE ON mac_invoice FOR EACH ROW 
BEGIN
DELETE FROM mac_invoice_split WHERE OLD.invoice_id = id;
END$$
DELIMITER ;"

id => "Invoice" table primary key
invoice_id =>foreign key of "Invoice" in "Invoice_split" table

1 Answer 1

1

you should try this

  WHERE OLD.id = invoice_id;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.