I want to sum 3 rows but when row1 is NULL i want to skip it to sum all other rows, with this i am getting an error:
CREATE TRIGGER sum_total_test_before_insert
BEFORE INSERT ON test
FOR EACH ROW
BEGIN
IF (NEW.row1 IS NULL) THEN
SET NEW.Total = (NEW.row2 + NEW.row3);
ELSE
SET NEW.Total = (NEW.row1 + NEW.row2 + NEW.row3);
END IF;
#1064 – Something is wrong in your syntax near ” in line 5
Thanks for your help.
I expect to have a correct syntax
New contributor
9083ja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.