Search code examples
mysqldatabasetriggersinnodb

error in your SQL syntax creating MySQL trigger


I try create trigger

CREATE TRIGGER `aster_users2` after
update ON `aster_users` FOR EACH ROW
BEGIN  update event set flag=1 where
id=1; END;

but got next error

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'end' at line 6

have suggestion to solve this problem ?


Solution

  • Try removing the semi-colons from your statements.

    If you'd like to keep your semi-colons,

    DELIMITER $$
    CREATE TRIGGER `aster_users2` after
    update ON `aster_users` FOR EACH ROW
    BEGIN  update event set flag=1 where
    id=1;  
     END$$
    DELIMITER ;