请问下面的mysql触发器为什么总是提示“end if end ”处有错误? /创建触发器的语句报错应该先写on 后写 before insert吧CREATE TRIGGER domain_Fill ON `web_record` BEFORE INSERTFOR EACH ROWBEGINIF(LOCATE(':/',NEW.`req_uri`))THENSET NEW.`domain`=SUBSTRING_INDEX(SUBSTRING_INDEX(NEW.`req_uri`,'/',3),'/',-2)END IFEND
mysql insert触发器错误,if then set mysql 的sql语句如下:mysql>;delimiter/create trigger sitedata_ins2before insert on userfor each rowBeginIf not exists(select 1 from user_data where d_id=new.id)theninsert into user_data(d_id,d_name)values(new.id,new.name);END IF;end;delimiter;或者简单一点:mysql>;delimiter/create trigger sitedata_ins2before insert on userfor each rowBegininsert into user_data(d_id,d_name)values(new.id,new.name);end;delimiter;二种方法都可以,建议你用第一种
mysql触发器错误 呵,你这个过程很多语法错误及处理逻辑错误啊我只帮你修改了语法错误,至于逻辑错误,你自己根据你的需求去修改调整吧:CREATE TRIGGER test AFTER INSERT ON skt15 FOR EACH ROWBEGINDECLARE not_found,price INT DEFAULT 0;DECLARE id,b varchar(30);DECLARE cur_1 CURSOR FOR SELECT skf595 FROM skt14 WHERE skf595=b;DECLARE CONTINUE HANDLER FOR NOT FOUND SET not_found=1;SET b=new.skf625;OPEN cur_1;WHILE not_found=0 DOFETCH cur_1 INTO id,price;END WHILE;SET a=price+new.skf635;UPDATE skt14 set skf617=a WHERE skf595=id;CLOSE cur_1;END;