update GoodPurchasePlan set orgUnit_id = (select md.oid from (select min(td.orgUnit_id) as oid,td.goodPurchasePlan_id as pid from(select it.id, it.orgUnit_id,it.goodPurchasePlan_id from GoodPurchaseItem it inner join  goodpurchasePlan p on p.id = it.goodPurchasePlan_id) td group by td.goodPurchasePlan_id) md where md.pid = id);