mysql编写触发器报错

触发器创建代码

/* 触发器 */
CREATE TRIGGER chufaqi BEFORE INSERT 
ON `customer`
FOR EACH ROW 
BEGIN
  /*INSERT INTO test(`name`,account,pwd,money) SELECT c.`name`,c.`account`,c.`pwd`,c.`money` FROM customer AS c ORDER BY id DESC LIMIT 1;*/
  INSERT INTO test VALUES (NULL,"111","111","111",123.0);
END;

报错:

错误代码: 1064
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 '' at line 7

解决:

BEGIN 后面加上; BEGIN;
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐