mysql触发器练习,求指教哪里出错。 50
CREATETRIGGERnihaoafte1rAFTERINSERTONnihaoFOREACHROWBEGINDECLAREcintDEFAULT0;SETc=(SE...
CREATE TRIGGER nihaoafte1r AFTER INSERT ON nihao
FOR EACH ROW
BEGIN
DECLARE c int DEFAULT 0;
SET c=(SELECT COUNT(*) FROM nihao WHERE xingbie ="00" AND id =NEW.id);
if c>0 THEN
update nihao SET xingbie="aqww" WHERE id = NEW.id;
ELSE
SET c=0;
END IF ;
END;
不会写触发器,随便练习写着玩,到底哪里出错了,老是报错,求大神指教。 展开
FOR EACH ROW
BEGIN
DECLARE c int DEFAULT 0;
SET c=(SELECT COUNT(*) FROM nihao WHERE xingbie ="00" AND id =NEW.id);
if c>0 THEN
update nihao SET xingbie="aqww" WHERE id = NEW.id;
ELSE
SET c=0;
END IF ;
END;
不会写触发器,随便练习写着玩,到底哪里出错了,老是报错,求大神指教。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询