I have written my trigger like this
CREATE TRIGGER `update_total_duration` AFTER UPDATE ON `sales_activity`
FOR EACH ROW thisTrigger:BEGIN
IF(NEW.activity_id=4)
THEN LEAVE thisTrigger;
ELSEIF NOT EXISTS
(SELECT 1 FROM sales_duration_update WHERE user_id = NEW.user_id AND date = CURDATE())
THEN INSERT INTO sales_duration_update (user_id,date,total_duration) VALUES (NEW.user_id,CURDATE(),NEW.duration);
ELSE
//problem is here when total_duration = total_duration + NEW.duration
UPDATE sales_duration_update SET total_duration = total_duration + NEW.duration WHERE user_id = NEW.user_id AND date = CURDATE();
END IF;
END
Problem is here in code
total_duration = total_duration + NEW.duration
where both variable are timestamp
variable.How can I add two timestamp
variables in trigger?