insert,update商品數據時需要把content中只截取前8個圖片tirgger語句:create trigger tri_goods_update AFTER UPDATEon ims_ewei_shop_goods for each rowbeginset @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 THENupdate ims_ewei_shop_goods set content = CONCAT(substring_index(old.content,'absmiddle',-(@gcount - 8)),'absmiddle" >') where id = new.id;END IF;END觸發器創建,和修改執行后沒有報錯,content中的數據沒有改變.
添加回答
舉報
0/150
提交
取消