简体   繁体   中英

MySQL trigger syntax error near CREATE TRIGGER

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 ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM