你要把YID改成什么值啊,
还有就是,你要在什么情况下更改表单,是FOR UPDATE ,INSERT ,DELETE??

解决方案 »

  1.   

    --你的更新方法有问题吧?--应该这样:
    update a set cardid=b.yid
    from 表1 a,表2 b
    where a.readerid=b.sid
      

  2.   

    --示例--示例数据
    create table 表1(cardid varchar(10),readerid varchar(10))
    insert 表1 select 'ty001','001'
    union  all select 'ty002','002'create table 表2(sid varchar(10),yid varchar(10))
    insert 表2 select '001','1111'
    union  all select '002','2222'
    go--更新
    update a set cardid=b.yid
    from 表1 a,表2 b
    where a.readerid=b.sid--显示处理结果
    select * from 表1
    go--删除测试
    drop table 表1,表2/*--测试结果cardid     readerid   
    ---------- ---------- 
    1111       001
    2222       002(所影响的行数为 2 行)
    --*/
      

  3.   

    估计你更新的时候没有设置关联条件,从而导致更新的结果是全部更新了同一个yid了
      

  4.   

    update 2 set yid=1.cardid from 1 where 2.sid=right(1.cardid,3)
    或是
    update 2 set yid=1.cardid from 1 where 2.sid=replace(1.cardid,'','ty')
      

  5.   

    update table1 set cardid=(select yid from table2 where table1.readerid=table2.sid)
      

  6.   

    谢谢zjcxc(邹建)的示范,在这个例子确实可行,也感谢其他人回复。