当Query执行后,可以用以下方式传给变量:
var I: integer;
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select count(a) from mytable.db where a<400')
Query1.Open;
I:=Query1.Fields[0].AsInteger;
Label1.Caption:=IntToStr(I);
end; //在Label1上反映出count结果来
Query1.SQL.Add('Select count(a) as countA form mytable.db where a<400');
Query.Active:=True;
Label.Caption:=IntToStr(Query1.FieldByName('countA').AsInteger);