有两个表如下:A表   id   name          B表   id   name
       1   null                 1     a
       2   null                 2     b
       3   null                 3     c两个表的id项是对应的,A表里的name属性为空,现在要把B表里面的name的数据复制到A表的name属性中,请问怎么用sql语句实现啊?

解决方案 »

  1.   

    update A a set a.name = select b.name from B b where a.id = b.id
      

  2.   

    update tablea
    set name = (select name from tableb where tablea.id = tableb.id)
      

  3.   


    UPDATE A a
       SET a.NAME = (SELECT b.NAME
                       FROM B b
                      WHERE a.ID = b.ID)
     WHERE EXISTS (SELECT 1
                     FROM B b
                    WHERE a.ID = b.ID)
      

  4.   

    to Eric_1999(╙@^@╜):快要无处不在啦,嘎嘎