如果不行,就这样子试试.但有点麻烦.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;
谁说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
set f1 = b.f1
from b
where 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;
update a
set f1 = b.f1
from b
where a.a1 = b.a1
我试了一下,错误提示为:语法错误(操作符丢失)在查询语句表达式‘b.f1
from b’中
如果用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
set f1 = b.f1
from b
where a.a1 = b.a1