tab a (col1,col2)
tab b (col1,col3)update a set a.col1=b.col3 from a,b where a.col1=b.col1这句在SQLserver可以执行,在oracle下不行。请教在oracle下面怎么改?100分相送!

解决方案 »

  1.   

    update a set a.col1=(select b.col3 from a,b where a.col1=b.col1)
      

  2.   

    update a 
    set
    a.col1=(select col3 from a,b where a.col1=b.col1)
    where a.col1=b.col1
      

  3.   

    update a 
    set
    a.col1=(select col3 from a,b where a.col1=b.col1)
    where a.col1=b.col1 AND B.COL1 IS NOT NULL
      

  4.   

    jiezhi(西域浪子) 你寫的好像不太嚴禁的
      

  5.   

    致jiezhi(西域浪子) 和  ccbzzp(ccbzzp)
    我把你们的语句在sqlplus试了一下,系统提示
    ORA-00904: invalid column namewhere a.col1=b.col1
                   *
      

  6.   

    update a
    set
    a.col1=(select col3 from a,b where a.col1=b.col1)
    where a.col1=(select a.col1 from a,b where a.col1=b.col1)
      

  7.   

    SQL> select * from a;                                   COL1 COL2
    --------------------------------------- ---------------------------------------
                                          1 100
                                          2 200SQL> select * from b;                                   COL1 COL3
    --------------------------------------- ---------------------------------------
                                          1 900
                                          3 700SQL> 
    SQL> update a
      2  set
      3  a.col1=(select col3 from a,b where a.col1=b.col1)
      4  where a.col1=(select a.col1 from a,b where a.col1=b.col1)
      5  ;1 row updatedSQL> select * from a;                                   COL1 COL2
    --------------------------------------- ---------------------------------------
                                        900 100
                                          2 200SQL>
      

  8.   

    当然select a.col1 from a,b where a.col1=b.col1只能返回一条记录
      

  9.   

    写个简单的存储过程吧,用游标或者动态sql来解决你的问题
      

  10.   

    用cursor好了,不会很困难的。。
      

  11.   

    用sqlplus可以执行又表吗?可以用ado 的 pconnect->excute()来执行吗?
      

  12.   

    真是的Trigger竟然没人认识,算了,不用也罢,你们慢慢去写什么cursor、Procedure吧
      

  13.   

    update a
      2  set
      3  a.col1=(select col3 from a,b where a.col1=b.col1)
      4  where a.col1=(select a.col1 from a,b where a.col1=b.col1)
      5  ;
    改成
    update a
      2  set
      3  a.col1=(select col3 from a,b where a.col1=b.col1)
      4  where exists (select col3 from a,b where a.col1=b.col1);
    会快一些