mysql触发器没有执行,求指导!

insert,update商品数据时需要把content中只截取前8个图片
tirgger语句:
create trigger tri_goods_update AFTER UPDATE
on ims_ewei_shop_goods for each row
begin
set @gcount = (SELECT CAST((LENGTH('content') - LENGTH(REPLACE('content',"absmiddle", ""))) / LENGTH("absmiddle") AS signed) AS count FROM ims_ewei_shop_goods where id = new.id);
IF @gcount > 8 AND locate('

',old.content) = 0 THEN
update ims_ewei_shop_goods set content = CONCAT(substring_index(old.content,'absmiddle',-(@gcount - 8)),'absmiddle" >') where id = new.id;
END IF;
END
触发器创建,和修改执行后没有报错,content中的数据没有改变.


LEATH
浏览 2868回答 2
2回答

白猪掌柜的

触发器不要更新自己会造成循环,使用navica工具看看表上触发器是否成功,内容和选项是否正确
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL