ÓÐÁ½Õűí A B id hyid hyid newid 1 2 2 A 2 3 3 B ÏÖÔÚÒª½«a±íµÄhyid»»³Éb±íµÄnewid,Çë×¢Òâa±íÖеÄhyid²»ÊÇΨһµÄ oracleÖиà Ôõô´¦Àí
merge into a using b on (a.hyid=b.hyid) when matched then update set a.hyid=b.newid a.hyid ÔÚon¾äÖÐ,²»ÄÜÐÞ¸Ä
ÎÒÁíÍâÔÚa±íÖÐŪÁËÒ»ÌõÊý¾ÝhyºÍhyid±£³ÖÒ»Ö ²¢ÇÒÒòΪa±íÖеÄhyid²»ÊÇΨһµÄ,½á¹û´íÎóÎÞ·¨»ñµÃÎȶ¨ÐÐupdate a set hyid=( select newid from b where hyid=a.hyid) where exists( select 1 from b where hyid=a.hyid) SQL code: update a set a.hyid=(select newid from b where b.hyid=a.hyid and rownum<2) and exists (select 1 from b where b.hyid=a.hyid);