1

嗨,我坚持使用此触发器将值插入我的日志表的语法。使用 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 
4

1 回答 1

0

如下创建触发器:

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 ;
于 2012-11-21T03:25:03.493 回答