I followed Mosh’s code at my machine for Trigger and Insert.
I cannot find anything wrong from my scripts.
However, it just cannot work. Can anyone help?
Here is my code:
DELIMITER $$
CREATE TRIGGER payments_after_insert
AFTER INSERT ON payments
FOR EACH ROW
BEGIN
UPDATE invoices
SET payment_total = payment_total + NEW.amount
WHERE invoice_id = NEW.invoice_id;
END$$
DELIMITER ;
And the part for INSERT:
INSERT INTO payments
VALUES (DEFAULT, 5, 3, ‘2019-01-01’, 10, 1)
I execute the Trigger first and then the Insert part, but my invoices table just doesn’t update.
Anything wrong at my code?