table1( col_1a,col_1b,col_1c )
table2( col_2a,col_2b,col_2c )我想update table1,当col_1a=col_2a时将col_2b和col_2c赋值给col_1b和col_1c。谢谢!

解决方案 »

  1.   

    merge很容易解决的
    你自己查一下,这样印象深
      

  2.   

    merge是什么东西?我到什么地方去查?谢谢!
      

  3.   

    http://blog.chinaunix.net/u1/55091/showart_430716.html
    可以参考一下
      

  4.   

    多谢多谢,merge简直是太好了!
      

  5.   

    update table1 a
    set (col_1b,col_1c)=(select b.col_2b,b.col_2c  from table2 b where a.col_1a=b.col_2a(+))
    where exists (select 1 from table2 b where a.col_1a=b.col_2a(+))
      

  6.   

    update table1 set (col_1b,col_1c)=(select col_2b,col_2c from table2 where col_1a=col_2a)
    where col_1a exists (select col_2a from table2 where col_1a=col_2a)
      

  7.   

    不错,学习
    MERGE INTO TABLE1 A
    USING TABLE2 B
    ON A.COL_1A = B.COL_2A
    WHEN MATCHED THEN
    UPDATE A.COL_1B = B.COL_2B,
    A.COL_1C = B.COL_2C;
      

  8.   

    merge into table a using table b
    on a.col=b.col
    when matched then
    update set a.col=b.col
    a.col1=b.col1