AdoQuery1.sql.add(selet * from Tab_Name where bone ='1997'; AdoQuery1.open;nCount:=AdoQuery1.RecordCount;或者如果表已经打开: AdoTable1.first; nCount:=0; while AdoTable1.eof do begin if AdoTable1.FieldByName('bone').AsString='1997' then nCount:=nCount+1; AdoTable1.next; end;result:=nCount;
TSQLQuery1.frist; Reapet if TSQLQuery1.filedbyname('出生').asstring = '97' then SUM := SUM + 1; //SUM为一个变量,作为计数器使用,初植为0 TSQLQuery1.Next; until TSQLQuery1.eof TSQLQuery1.frist;
select count(*) from yourtable where birthyear = '97'
用动态sql查询 你可以用edit或者别的控件来输入你的条件 …… sSql:='select * from tableName where 1=1 '; sWhere:='and +你的条件变量' …… 注意引号的书写就ok啦
AdoQuery1.open;nCount:=AdoQuery1.RecordCount;或者如果表已经打开:
AdoTable1.first;
nCount:=0;
while AdoTable1.eof do
begin
if AdoTable1.FieldByName('bone').AsString='1997' then
nCount:=nCount+1;
AdoTable1.next;
end;result:=nCount;
Reapet
if TSQLQuery1.filedbyname('出生').asstring = '97' then
SUM := SUM + 1; //SUM为一个变量,作为计数器使用,初植为0
TSQLQuery1.Next;
until TSQLQuery1.eof
TSQLQuery1.frist;
你可以用edit或者别的控件来输入你的条件
……
sSql:='select * from tableName where 1=1 ';
sWhere:='and +你的条件变量'
……
注意引号的书写就ok啦