触发错误INSERT Mysql

时间:2015-07-10 12:02:38

标签: mysql sql

我尝试通过phpmyadmin和body INSERT创建触发器AFTER UPDATE

BEGIN
INSERT INTO updatespersonal SET (user, time, type, operator) VALUES (NEW.idDetailToUsers, CURRENT_TIMESTAMP(), "detailtousers", "update");
END

但是我得到了错误,因为我无法理解:

  第2行

1064

双引号可能有问题吗?

3 个答案:

答案 0 :(得分:4)

插入语句出错,请删除 SET 关键字:

INSERT INTO updatespersonal (user, time, type, operator) VALUES (NEW.idDetailToUsers, CURRENT_TIMESTAMP(), "detailtousers", "update");

答案 1 :(得分:1)

您的语法不正确。使用 INSERT INTO 时,您无需SET

您的代码应为:

BEGIN
INSERT INTO updatespersonal (user, time, type, operator) VALUES (NEW.idDetailToUsers, CURRENT_TIMESTAMP(), "detailtousers", "update");
END

答案 2 :(得分:0)

2个问题

  1. 在插入INTO中不需要SET
  2. 您使用关键字作为列名用户。将其括在""

    BEGIN INSERT INTO updatespersonal ("user", time, type, operator) VALUES (NEW.idDetailToUsers, CURRENT_TIMESTAMP(), "detailtousers", "update"); END