gpt4 book ai didi

MySQL触发器: ERROR 1064 (42000): You have an error in your SQL syntax

转载 作者:行者123 更新时间:2023-11-29 15:09:17 26 4
gpt4 key购买 nike

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

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 

触发器内的插入语句有什么问题

最佳答案

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;

关于MySQL触发器: ERROR 1064 (42000): You have an error in your SQL syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1293957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com