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:
CREATE TRIGGER payments_after_insert
AFTER INSERT ON payments
FOR EACH ROW
SET payment_total = payment_total + NEW.amount
WHERE invoice_id = NEW.invoice_id;
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?