-- 使用当前(子表)表某字段更新 对应行记录其他字段 (存在主子表关系) left join
update
(
select a.* from ic_purchasein_b a
left join ic_purchasein_h b on b.cgeneralhid = a.cgeneralhid
where b.pk_org = '0001A1100000001BN4N6'and (vdef2 is not null and vdef2 <> '~')
) t
set t.nqtunitnum = (
select nnum
FROM (
select cunitid --计量单位
,nnum --实收数量
,ic_purchasein_h.vbillcode
,cgeneralbid
from ic_purchasein_b ic_purchasein_b
left join ic_purchasein_h ic_purchasein_h on ic_purchasein_h.cgeneralhid = ic_purchasein_b.cgeneralhid
where ic_purchasein_h.pk_org = '0001A1100000001BN4N6'and (vdef2 is not null and vdef2 <> '~')
) b where b.cgeneralbid = t.cgeneralbid
)
-- 使用当前(子表)表某字段更新 对应行记录其他字段 (存在主子表关系) left join
最新推荐文章于 2022-02-13 17:57:13 发布