A.FIELD1=B.FIELD2 ? 搞错了吧???

解决方案 »

  1.   

    UPDATE A SET FIELD1= (SELECT FIELD2 FROM B WHERE A.EMPLID = B.EMPLID)
      

  2.   

    我假设你的两个表的关系为   A.EMPLID = B.EMPLID
      

  3.   

    update a set field1= (select filed2 from a,b where A.EMPLID = B.EMPLID) where rowid in (select a.rowid from a,b where A.EMPLID = B.EMPLID)
      

  4.   

    update a set a.FIELD1=B.FIELD2
    where exists (select 1 from B where B.emplid=a.emplid)
      

  5.   

    doulikeme(来去无踪)的回答更好!
      

  6.   

    这题目都没表达清楚哎方法楼上的都不错。不过我更支持GerryYang(轻尘) 的就不知道楼主到底要什么了
      

  7.   

    这样比较简洁
    Update A Set A.F1=B.F2
    Where Exists (Select 1 From B Where B.ID=A.ID)
      

  8.   

    呵呵,doulikeme(来去无踪)和GerryYang(轻尘)都回答的挺好所以我就接分吧
      

  9.   

    不枉看这一页!
    原来还可以这样:
    Update A Set A.F1=B.F2
    Where Exists (Select 1 From B Where B.ID=A.ID)
      

  10.   

    Update A Set A.F1=B.F2 where a.a=b.a
      

  11.   

    呵呵,我是没表达清楚,应该是A.EMPLID=B.EMPLID,各位都看出来了!!!!!!!但以上方法好像是只对单独一条记录有效,A,B表有多条符合A.EMPLID=B.EMPLID的记录,
    执行以上指令,会提示记录不唯一.各位看看有啥高招?!!!!!!!!!  稍等,下次再散分吧!!!!  呵呵
      

  12.   

    update a set field1= (select max(field2) from a,b where A.EMPLID = B.EMPLID) where exists(select 1 from b where A.EMPLID = B.EMPLID); 如果你查询出的field2不唯一的话,你应该根据你的实际情况去选择是用什么样的值去更新field1这里我是例举用最大值去更新
      

  13.   

    update a set field1= (select max(field2) from b where A.EMPLID = B.EMPLID) where exists(select 1 from b where A.EMPLID = B.EMPLID);前面错了一点
      

  14.   

    update a set a.FIELD1=B.FIELD2
    where exists (select 1 from B where B.emplid=a.emplid) -- 这样不能执行呀 !!!!