我有表A 字段有 a ,b
表B字段有a,b
当表A中的a等于表B中的b时,我想update 表A的a值为B中的b
具体的SQL语句是怎么样的呢?

解决方案 »

  1.   

    update A set A.a=(select B.b from A where A.a=B.b) where exists (select 1 from B where A.a=B.b);
      

  2.   

    update A set A.a=(select B.b from B where A.a=B.b) where exists (select 1 from B where A.a=B.b);
      

  3.   

    update A set A.a=(select B.b from B where A.a=B.b) where exists (select 1 from B where A.a=B.b);
      

  4.   

    当表A中的a等于表B中的b时,我想update 表A的a值为B中的b
    根据你的描述已然相等了还更新个什么。
      

  5.   

    问题搞清楚啊!
    估计你的问题无非就是更新A表的数据为B表的数据!UPDATE A a SET (col1,col2)=
    SELECT col1,col2
    FROM B b 
    WHERE a.col1=b.col2;
      

  6.   


    是的,条件都已经是A表的a字段等于B表的b字段了,还要进行什么更新吗?