……
table1.first;
while not table1.eof do
begin
table2.filter:='name='''+table1.fieldbyname('name').asstring+'''';
if talbe2.recordcount>1 then
showmessage('存在');
end;
Sql.Add('select username from table where username=:a');
Parmas[0].AsString:=Name;//Name 为要判断的用户名
Open
if Eof then
ShowMessage('不存在')
else
ShowMessage('存在');