-- 使用当前(子表)表某字段更新 对应行记录其他字段 (存在主子表关系) 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 <> '~')
) tset t.nqtunitnum = (select nnumFROM (select cunitid --计量单位,nnum --实收数量,ic_purchasein_h.vbillcode,cgeneralbidfrom ic_purchasein_b ic_purchasein_bleft join ic_purchasein_h ic_purchasein_h on ic_purchasein_h.cgeneralhid = ic_purchasein_b.cgeneralhidwhere ic_purchasein_h.pk_org = '0001A1100000001BN4N6'and (vdef2 is not null and vdef2 <> '~')) b where b.cgeneralbid = t.cgeneralbid
)