各位大侠,有问题请教,帮帮小弟。
我是用delphi7连接access数据库,想把一个表中的某一列“对号入座”到另一个表中的对应列,但是总是报错。代码如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Update table1,table2 Set table1.zhangfu = table2.zhangfu ');
SQL.Add(' Where (table1.A = table2.A) and (table1.B = table2.B)');
ExecSQL;
end;
end;
报错
语法错误(操作符丢失)在查询表达式'table2.zhangfu'中。
...全文
141912打赏收藏
语法错误(操作符丢失)在查询表达式' '中。
各位大侠,有问题请教,帮帮小弟。 我是用delphi7连接access数据库,想把一个表中的某一列“对号入座”到另一个表中的对应列,但是总是报错。代码如下: procedure TForm1.Button1Click(Sender: TObject); begin With ADOQuery1 do begin Close; SQL.Clear; SQL.Add(' Update table1,table2 Set table1.zhangfu = table2.zhangfu '); SQL.
用一句sql从一个表里面取出数据来更新另外一个表里面对应的值:
update table1,table2 set table1.column1=table2.column1 where table1.column2=table2.column2
语法错误(操作符丢失)在查询表达式‘table2.column1’中。
procedure TForm1.Button1Click(Sender: TObject);
begin
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Update a set a.zhangfu=b.zhangfu from table1 a,table2 b where a.A=b.A and a.B=b.B');
ExecSQL;
end;
end;
With ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add(' Update table1 Set table1.zhangfu = ( ');
SQL.Add(' select table2.zhangfu from table2 Where (table1.A = table2.A) and (table1.B = table2.B))');
ExecSQL;
end;