如果 表A 中有个字段a里面的值是空的,我想把表B中的a值,赋值给表A,应该写怎样的一个sql?

解决方案 »

  1.   

    问题是如何对应,如果a表和b表通过aid和bid字段连接
    update a set a=(select a from b where bid=a.aid)
    where exists(select 1 from b where bid=a.aid)
      

  2.   

    update a set a=(select a from b where c=a.c) 
    where exists(select 1 from b where c=a.c)
      

  3.   

    update a set a=(select a from b where c=a.c)
     where exists(select 1 from b where c=a.c) and a.a is null    :)