Hi all,
Im trying to create a trigger but keep getting a syntax error. Basically the trigger must be created after a insert on table_1 and update another table's fields with 1 depending on what was inserted into table_1 ( apple, orange, banana, grape )
CREATE TRIGGER trigger_name
AFTER INSERT ON table_1
FOR EACH ROW BEGIN
SET @something = (SELECT name FROM table_1 WHERE id =
NEW.id);
IF @something = 'apple' THEN
(UPDATE table_2 SET field = field + 1);
ELSEIF @something = 'orange' THEN
(UPDATE table_2 SET field = field + 1);
ELSEIF @something = 'banana' THEN
(UPDATE table_2 SET field = field + 1);
ELSEIF @something = 'grape' THEN
(UPDATE table_2 SET field = field + 1);
ENDIF;
END;
ANY help would be greatly appreciated!! :-)