我的触发查询:
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`users_AFTER_INSERT` AFTER INSERT ON `users` FOR EACH ROW
BEGIN
UPDATE test.users
SET enabled=1
FROM Inserted i
WHERE username = i.username
END
它抱怨这部分:SET enabled=1
。我试过添加引号,没有帮助。
很可能语法错了,但我无法弄清楚这里到底出了什么问题。
编辑:
或者可以这样做吗?
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`users_AFTER_INSERT` AFTER INSERT ON `users` FOR EACH ROW
BEGIN
UPDATE test.users
SET enabled=1
WHERE username = NEW.username;
END
答案 0 :(得分:1)
删除from inserted
查询:
delimiter |
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`users_AFTER_INSERT` AFTER INSERT ON `users` FOR EACH ROW
BEGIN
UPDATE test.users
SET enabled=1
WHERE username = i.username;
END
|
delimiter ;