请问高手如何在ACEESS中实现如下操作:
A表:
  kh      sw
  0001    1
  0005    2
  ....
B表
  kh      sw    bb
  0001    
  0002
  ....
  0005
  ....
将B表中sw项更新为A表中对应的sw?请问如何办。

解决方案 »

  1.   


    update A表 set  sw=B表.sw from B表 where A表. kh=B表.kh
      

  2.   

    update A表 set  sw=B表.sw from B表 where A表. kh=B表.kh运行报错,要求输入a.sw的值
      

  3.   

    update A表 set  sw=b.sw from A表 a, B表 b where a. kh=b.kh
      

  4.   

    搞错了,如下:
    update B表 set  sw=a.sw from A表 a, B表 b where a. kh=b.kh
      

  5.   

    A表.first
    B表.first
    while not A表.eof do 
      begin
        while not B表.eof do
          begin
            if B表.fieldbyname('kh').asstring = A表.fieldvalue['kh'] then
              begin
                A表.fieldbayname('sw') := B表.fieldvalue['sw'];
                A表.next;
                B表.next;
                break;
              end
            else
              B表.next; 
          end;
      end;
      

  6.   

    也不行啊,报在"from a,b where a.kh=b.kh"中操作符丢失
      

  7.   

    我要求是在ACEESS中实现啊,不是在Delphi中,
      

  8.   

    update 表B Inner Join 表A on 表A.kh=表B.kh set 表B.sw=表A.sw
      

  9.   

    update B set B.SW=A.SW where B.kh=A.kh
      

  10.   

    update 表B Inner Join 表A on 表A.kh=表B.kh set 表B.sw=表A.sw在ACCESS2003下测试通过