I am new to SQL and I don't know where to get help. I faced a problem while using the trigger, but it doesn't response. This is my code here:
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 ;
Here is the second part:
INSERT INTO payments
VALUES (DEFAULT, 5, 3, '2019-01-01', 10, 1)
I execute the first part, then the second. Strangely the new data has been inserted, but the triggers don't.
Can someone help me? I have been searching for the answers for few days and I don't know how to solve it.
Thank you in advance.