表A
id    name  
1     11
2     22
3     33
4     44
表B
id    name  
1     111
2     222
3     333我想使操作后表A数据变为表A
id    name  
1     111
2     222
3     333
4     44如何操作。ps  简单的以为 update a t1 set t1.name = (select t2.name from b t2 where t1.id = t2.id);
这个语句不对
因为执行这个语句后 表a的数据变为表A
id    name  
1     111
2     222
3     333
4     大家可以试试。
如何解决?

解决方案 »

  1.   

    update a t1 set t1.name = (select t2.name from b t2 where t1.id = t2.id)where exisits (select 1 from b t3 where t1.id=t3.di)
      

  2.   

    update a t1 set t1.name = (select t2.name from b t2 where t1.id = t2.id)
      where exists(select 1  from b  where t1.id = b.id);
    update时记得要加条件
      

  3.   

    csdn高手还是很多的。
    也很有效率 不到一分钟。 昨天一个帖子也是。