#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在第12行的''附近使用正确的语法
delimiter |
CREATE TRIGGER `pointhistorytrigger` AFTER UPDATE ON `points`
FOR EACH ROW BEGIN
IF NEW.is_open='4'
THEN
INSERT into point_history (`idpoints`,`idmembers`,`action_time`,`action_type`)
VALUES (OLD.idpoints,NEW.idmembers,NOW(),'3');
ELSE IF NEW.is_open='3'
THEN
INSERT into point_history (`idpoints`,`idmembers`,`action_time`,`action_type`)
VALUES (OLD.idpoints,NEW.idmembers,NOW(),'2');
END IF;
END;
| delimiter ;
答案 0 :(得分:0)
delimiter |
CREATE TRIGGER `pointhistorytrigger`
AFTER UPDATE ON `points`
FOR EACH ROW
BEGIN
IF NEW.is_open='4' THEN
INSERT into point_history (`idpoints`,`idmembers`,`action_time`,`action_type`)
VALUES (OLD.idpoints,NEW.idmembers,NOW(),'3');
ELSEIF NEW.is_open='3' THEN
INSERT into point_history (`idpoints`,`idmembers`,`action_time`,`action_type`)
VALUES (OLD.idpoints,NEW.idmembers,NOW(),'2');
END IF;
END | -- <<== remove the semi colon here
delimiter ;
答案 1 :(得分:0)
如果您在MySQL中使用 else-if ,则必须使用ELSEIF
而不是ELSE IF
。在你的陈述中,其他一切都很好。