gpt4 book ai didi

php - MySql 触发器不工作,语法错误

转载 作者:行者123 更新时间:2023-11-29 22:32:33 29 4
gpt4 key购买 nike

我尝试创建以下触发器,但它不起作用:

delimiter //
CREATE TRIGGER DeleteFeature
AFTER DELETE ON Features
FOR EACH ROW BEGIN
IF (OLD.FeatureID IN (SELECT FeatureID FROM GroupFeatures)) THEN
INSERT INTO DeletedFeatures VALUES (OLD.FeatureID, OLD.FeatureName, OLD.FeatureDescription);
END IF;
END;
//

出现以下错误:

“#1064 - 您的 SQL 语法有错误;请检查与您的 MySQL 服务器版本相对应的手册,了解第 8 行‘//’附近使用的正确语法”

知道问题可能是什么吗?

最佳答案

您是否通过删除分号并在 END 后添加 $$ 进行检查

DELIMITER $$
CREATE TRIGGER DeleteFeature
AFTER DELETE ON Features
FOR EACH ROW
BEGIN
IF (OLD.FeatureID IN (SELECT FeatureID FROM GroupFeatures)) THEN
INSERT INTO DeletedFeatures VALUES (OLD.FeatureID, OLD.FeatureName OLD.FeatureDescription);
END IF;
END $$
DELIMITER ;

关于php - MySql 触发器不工作,语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29686932/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com