update A From A SET A.a2 (select B.b2 from b where A.a1 = B.b1 and A.a2 != B.b2);

解决方案 »

  1.   

    update a SET A.a2 = (select B.b2  from b where A.a1 = B.b1 and A.a2 != B.b2);
      

  2.   

    呵呵,太粗心了
    去掉 from A
      

  3.   

    update A set 
        A.a2=(select B.b2 from B where B.b1=A.a1)
        where exists(select 1 from B where B.b1=A.a1 and B.b2<>A.a2);
      

  4.   

    这个问题挺简单的,我已经解决了,方法和bobfang的差不多。
    update A set 
      A.a2 =(select B.b2 from B where B.b1 = A.a1)
    WHERE A.a2 != (select B.b2 where  B.b1=A.a1  and  B.b2  <  >A.a2); 
    bzszp 和 w_tsinghua 两位的语句是错的。不满足 A.a1 = B.b1 and A.a2<>B.b2的 A.a2 值
    会被更新为 NULL.