gpt4 book ai didi

mysql - 创建触发器将 UNIX_TIMESTAMP() 插入日志表

转载 作者:行者123 更新时间:2023-11-30 23:25:41 25 4
gpt4 key购买 nike

您好,我坚持让这个触发器将值插入我的日志表的语法。使用phpmyadmin里面的sql选项卡执行sql语句前出现错误

`#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 8 `

这是我创建触发器的sql语句

CREATE TRIGGER after_insert_list  
AFTER INSERT ON list FOR EACH ROW
BEGIN
INSERT INTO log (user_id, action, date_log)
VALUES (
NEW.user_id,
NEW.action,
UNIX_TIMESTAMP()
);
END

最佳答案

像下面这样创建你的触发器:

delimiter |
CREATE TRIGGER testref
BEFORE INSERT ON test1FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END;
|
delimiter ;

关于mysql - 创建触发器将 UNIX_TIMESTAMP() 插入日志表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13485665/

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