update b set b.ff=a.ds from a,b where a.id=b.ff

解决方案 »

  1.   

    如果是查询,可以这样写:select ds from b left join a on a.id=b.ff
      

  2.   

    update b set b.ff=a.ds from a,b where a.id=b.ff
      

  3.   

    --建测试数据表
    create table a(id varchar(10), ds varchar(10))
    insert a 
    select '12',  '我' union all select 
    '13' , '你' union all select 
    '14',  '他' create table b(ff varchar(10))
    insert b 
    select '13' union all select
    '12' union all select
    '12' union all select
    '14'--测试
    update b set b.ff=a.ds from a,b where a.id=b.ff
    select * from b
    --结果
    ff




    --删除
    drop table a
    drop table b
      

  4.   

    好象不行了,不是全部数据都可以替换
    重新说明表
    a:          b:
    id   ds     id  ff   ef  
    001  我     1   002  工具
    002  你     2   004  方法
    003  他     3   002  似的
    004  gg     4   001  达到
    就是将表a的ds替换到表b中的ff项,转换为:
    b:
    id  ff  ef
    1   你  工具
    2   gg  方法
    3   你  似的
    4   我  达到
    比较简单的问题,一时想不起了,多谢各位,解决,马上给分!!!
      

  5.   

    update b set ff=a.ds from a,b where a.id=b.ff
      

  6.   

    --测试--测试数据
    create table a(id varchar(10),ds varchar(10))
    insert a  select '001','我'
    union all select '002','你'
    union all select '003','他'
    union all select '004','gg'create table b(id int,ff varchar(10),ef varchar(10))
    insert b  select 1,'002','工具'
    union all select 2,'004','方法'
    union all select 3,'002','似的'
    union all select 4,'001','达到'
    go--更新
    update b set ff=a.ds from a,b where a.id=b.ff--更新结果
    select * from b
    go--删除测试
    drop table a,b/*--测试结果id          ff         ef         
    ----------- ---------- ---------- 
    1           你          工具
    2           gg         方法
    3           你          似的
    4           我          达到(所影响的行数为 4 行)--*/
      

  7.   

    就算多列也一样啊,不就是那个update嘛
      

  8.   

    我知道,可能是我数据库里,两个子段格式不同的原因
    我用的是sql server2000
    辛苦大家了,我在试试看