有两张表A表和B表,A表有两个字段,KEY,VAL;B表有两个字段KEY,VAL,当A.KEY=B.KEY时,将A表VAL字段更新为B.VAL?如何实现?

解决方案 »

  1.   

    update a set val = (select b.val from A a,B b where a.key=b.key )
      

  2.   

    update a set val = (select b.val from A a,B b where a.key=b.key )
      

  3.   

    update a set val = (select b.val from A a,B b where a.key=b.key )
      

  4.   

    刚看错了 
    试试这个 update A a set a.val = (select val from B where key=a.key )
      

  5.   

    lz有oracle PL/SQL的书吗? 怀疑!!!
      

  6.   

    update table1 a 
    set a2=(select a.b2 from table1 a,table2 b where a.a1=b.b1) 
    where a1=(select a.a1 from table1 a,table2 b where a.a1=b.b1) 
      

  7.   

    update A a set a.val = (select val from B where key=a.key ) 正解update table1 a  
    set a2=(select a.b2 from table1 a,table2 b where a.a1=b.b1)  
    where a1=(select a.a1 from table1 a,table2 b where a.a1=b.b1)  这种方法自找麻烦。