MySQL触发器:ERROR 1064(42000):您的SQL语法有错误

时间:2009-08-18 13:44:34

标签: mysql triggers

我正在尝试创建一个监视表上更改的触发器,然后将这些更改插入到另一个表中,如下所示

CREATE TRIGGER userChangePasswd
BEFORE UPDATE ON originalTable
FOR EACH ROW
BEGIN
INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM  originalTable
END

mysql一直显示以下错误

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 'INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM ' originalTable at line 5

以下语句使用where子句标准

INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM  originalTable 

触发器中的insert语句有什么问题

1 个答案:

答案 0 :(得分:1)

CREATE TRIGGER `orgTbl_before_upd_tr` BEFORE UPDATE ON `orgTbl`
FOR EACH ROW
BEGIN
  INSERT INTO newTbl (field1, field2) VALUES (old.field1, old.field2);
END;