我有一个用户表名为user_infor,然后里面有两个字段分别是user_question,isprotected
我是想实现如果user_question若是没有填写东西进去,那么将isprotected设置为1
所以写了以下的触发器代码,不过不知道为何总是出现这样一个提示
“
错误码: 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
”
在网上查了一下很多人不是说是关键字的问题就是说是版本问题,有些不明所以,所以上来向大家请教下~~触发器代码:
DELIMITER $$CREATE
TRIGGER tri_protected BEFORE INSERT
ON user_infor
FOR EACH ROW
BEGIN IF new.user_question <> NULL THEN
SET new.isprotected = 1;
END$$
我是想实现如果user_question若是没有填写东西进去,那么将isprotected设置为1
所以写了以下的触发器代码,不过不知道为何总是出现这样一个提示
“
错误码: 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
”
在网上查了一下很多人不是说是关键字的问题就是说是版本问题,有些不明所以,所以上来向大家请教下~~触发器代码:
DELIMITER $$CREATE
TRIGGER tri_protected BEFORE INSERT
ON user_infor
FOR EACH ROW
BEGIN IF new.user_question <> NULL THEN
SET new.isprotected = 1;
END$$
TRIGGER tri_protected BEFORE INSERT
ON user_infor
FOR EACH ROW
BEGIN IF new.user_question <> NULL THEN
SET new.isprotected = 1;
end if
END$$
这个END IF哪去了?