update A a set a.字段1=(select b.字段2+100 from B b where a.字段=b.字段) where......

解决方案 »

  1.   

    update a set a.col=(select b.col+100 from b where
    a.pk=b.pk)
    where exists (select 1 from b where a.pk=b.pk);
      

  2.   

    后面的where 条件应该怎么写啊?我写的把B表里面所有的记录都选出来了
      

  3.   

    不是吧,如果select b.字段2+100 from B b where a.字段=b.字段
    返回多条的话,那你的update根本就无法执行了。
      

  4.   

    我想格式应该是这样的了,不过你要保证select b.字段2+100 from B b where a.字段=b.字段反回的只有一条记录.可以加多点条件限制.
    update A a set a.字段1=(select b.字段2+100 from B b where a.字段=b.字段) where......