I'm trying to create trigger in Mysql, and get the error:

check the manual that corresponds to your MySQL server version for the right syntax to  use near 'CREATE TRIGGER `foo`.`test` AFTER INSERT ON `foo`.`test` FOR EACH ROW BE' at line 2

in this trigger:

DELIMITER $$
SET @name2:='w';
CREATE TRIGGER `foo`.`test`
AFTER INSERT
    ON `foo`.`test`
    FOR EACH ROW BEGIN
    SELECT name1 INTO name2;
    END;
    $$
DELIMITER ;

What is wrong with line 2?

有帮助吗?

解决方案

try this:

  DELIMITER $$

 CREATE TRIGGER `foo`.`test` AFTER INSERT
ON `foo`.`test`
FOR EACH ROW BEGIN
SET @name2:='w';
SELECT name1 INTO @name2;
END$$
DELIMITER ;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top