改成这样
if table1.filedbyname('userno').asstring='gl' then
做统计建义还是用query
query1.clsoe;
query1.sql.clear;
query1.sql.add('select userno,count(userno) from 表名 group by userno');
query1.open;
showmessage(query1.fieldbyname('count(userno)').asstring);
//或showmessage(query1.fields[1].asstring);
query1.close;
if table1.filedbyname('userno').asstring='gl' then
做统计建义还是用query
query1.clsoe;
query1.sql.clear;
query1.sql.add('select userno,count(userno) from 表名 group by userno');
query1.open;
showmessage(query1.fieldbyname('count(userno)').asstring);
//或showmessage(query1.fields[1].asstring);
query1.close;
u:integer;
table1.first;
while not table1.eof do
begin
if copy(table1.filedbyname('userno').asstring,1,2)='gl' then
u:=u+1;
table1.next;
end;
更好的使用query来做
query1.clsoe;
query1.sql.clear;
query1.sql.add('select 用户编号 from 表名 where 用户编号 like '+'''gl%''');
query1.open;
u:= query1.recordcount;
或
query1.clsoe;
query1.sql.clear;
query1.sql.add('select count(用户编号) from 表名 where 用户编号 like '+'''gl%''');
query1.open;