a表字段名:
   a1   b1   c1   d1    f1   
b表字段名:
   a1   x    d     e    f1
a、b表的a1字段名一样,如果a、b表的a1字段值相同,用b表的f1去更新a1表的f1.
我是初学者,请大家帮忙。

解决方案 »

  1.   

    update a
    set f1 = b.f1
    from b
    where a.a1 = b.a1
      

  2.   

    update 语句不能用from 吧?我试了一下,不行。
      

  3.   

    如果不行,就这样子试试.但有点麻烦.ADO1.SQL.Text:='Select A.A1, B.F1 From A Left Outer Join B On A.A1=B.A1'
    ADO1.Open;
    While Not ADO1.Eof Do Begin
      ADO2.SQL.SQL.Text:='UpData B Set F1:=pF1 Where A1=:pA1';
      ADO2.Parameters.ParamByName('pF1').Value:= ADO1.FieldByName('F1').asString;
      ADO2.Parameters.ParamByName('pF1').Value:= ADO1.FieldByName('A1').asInteger;
      ADO2.ExecSQL;
    End;
      

  4.   

    怎么不能用from 看看SQLServer的帮助吧老兄
      

  5.   

    回复人: firetoucher(风焱) ( ) 信誉:129  2003-07-07 16:43:00  得分:0 
     
     
      update a
    set f1 = b.f1
    from b
    where a.a1 = b.a1
     
     
    我试了一下,错误提示为:语法错误(操作符丢失)在查询语句表达式‘b.f1
    from b’中
      

  6.   

    谁说update不能用from啊?如果不行可能是采用access数据库吧!
    如果用MSSQL或sybase数据库则可以用下面语句
    update a set a.f1=b.f1 from b where a.a1=b.a1
    如果用access数据库
    update a inner join b on a.a1=b.a1 set a.f1=b.f1
      

  7.   

    就是access,按你的方法,还是不行。
      

  8.   

    update a
    set f1 = b.f1
    from b
    where a.a1 = b.a1