另外你的例子中A表第一条记录是错的 sql.add('select * from A where (A.品种=B.品种)and(A.数量=B.数量)and(A.价格=B.价格)')
with query1 do begin close; sql.clear; sql.add('select * from A ,B where (A.品种=B.品种) and (A.价格=B.价格)'); open; end;
select 品种,价格,合计 from A ,b where (A.品种=B.品种)and(A.价格=B.价格)and(A.合计=B.合计)
a.first; while not a.eof do begin b.first; while not b.eof do begin if a.locate('field1;field2;',vararrayof([b.fields[1].value....]),[]) then showmessage('same'); b.next; end; a.next; end;
sql.add('select * from A where (A.品种=B.品种)and(A.数量=B.数量)and(A.价格=B.价格)')
begin
close;
sql.clear;
sql.add('select * from A ,B where (A.品种=B.品种) and (A.价格=B.价格)');
open;
end;
where (A.品种=B.品种)and(A.价格=B.价格)and(A.合计=B.合计)
while not a.eof do
begin
b.first;
while not b.eof do
begin
if a.locate('field1;field2;',vararrayof([b.fields[1].value....]),[]) then
showmessage('same');
b.next;
end;
a.next;
end;