update yhda a set a.sbbm=(select b.xlbm from xjnd_xlbm b where a.hh=b.bh) where (to_number(a.hh) between 11800000 and 11946123) and exists(select b.* from xjnd_xlbm b where a.hh=b.bh)我没估计错的话,你原来的语句并不能达到你的目的,你用两三条记录去测试一下。

解决方案 »

  1.   

    我想rs_net的意思是,如果你的两个表关于hh,和bh不是一一对应的就会出问题。
    如:
    yhda.hh    xjnd_xlbm.bh
    1            1
    2            2
    3
    当yhda.hh=3的时候,你的SQL语句会将yhda.sbbm赋为NULL
      

  2.   

    各位,这个语句可以的。我在另一个数据库运行
    update yhda a set sbbm=(select xlbm from xjnd_xlbm b where b.bh=a.hh)
    where hh in (select bh  from xjnd_xlbm )136324 rows updated in 15.062 seconds b.bh& a.hh都是主建。
      

  3.   

    update (select a.sbbm,b.xlbm where yhda a,xjnd_xlbm b where a.hh=b.bh and to_number(a.hh) between 11800000 and 11946123) set sbbm=xlbm