[英]Correct MySQL Syntax for this trigger?
Trying to create a simple trigger that after a table update, it checks if a count (InvalidLogins) is over 4, and if so, sets the field 'LockedOut' to 1. Below is how I am attempting to create the trigger, this is my first trigger for MySQL though and I can't get it to work. 尝试创建一个简单的触发器,该触发器在表更新后会检查计数(InvalidLogins)是否超过4,如果是,则将“ LockedOut”字段设置为1。以下是我尝试创建触发器的方式,这是我的第一个MySQL触发器,但是我无法使其正常工作。
CREATE TRIGGER update_user_lockout after update ON members
FOR EACH ROW SET LockedOut = 1 where invalidLogins < 4
The error that MySQL returns is: Error Code: 1064. You have an error in your SQL syntax; MySQL返回的错误是:错误代码:1064。 check the manual that corresponds to your MySQL server version for the right syntax to use near '.LockedOut = 1 where invalidLogins < 4' at line 2
检查与您的MySQL服务器版本相对应的手册,以在'.LockedOut = 1附近使用正确的语法,其中invalidLogins <4'在第2行
delimiter |
CREATE TRIGGER update_user_lockout before update ON members
FOR EACH ROW
IF NEW.invalidLogins < 4 THEN
SET NEW.LockedOut = 1;
END IF;
END
|
delimiter ;
NEW
NEW
引用当前记录 ;
;
. ;
;
which is too early before
trigger to change values before updating before
触发器来更改值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.