场景:当物料表的分组前台跟后台不一样的情况或是前台删除分组提示有明细数据时;
一、查询出分组对应的fid;
select * from T_BD_MATERIALGROUP_L where fname like '%000%'
二、找出对应的物料fnumber;
select a.fnumber from T_BD_MATERIAL a
left join (select fid,fname From T_BD_MATERIALGROUP_L ) t4 on a.FMATERIALGROUP=t4.fid
where t4.fname like '%000%' and FMATERIALGROUP=16416826
三、更新;
update a set a.FMATERIALGROUP=12258320 from T_BD_MATERIAL a
left join (select fid,fname From T_BD_MATERIALGROUP_L ) t4 on a.FMATERIALGROUP=t4.fid
where t4.fname like '%000%' and FMATERIALGROUP=16416826
原文地址:http://blog.51cto.com/yataigp/2107587
时间: 2024-10-28 14:39:33