开发者

How to DO MYSQL TRIGGER FOR DELETE Entry Before UPDATE

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开发者_如何学Python 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


you should try this

  WHERE OLD.id = invoice_id;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜