Page 1 of 1
get the total count of record
Posted: Mon Mar 13, 2006 1:16 am
by jaylin
hi all,
i want to get the total number of record for the specified query that contains
subquery and
limit. although i set the limit as like that
, if there is abt 100 records, i want to show total count as a new field data, and the rest data. is there any way?
regards,
Posted: Mon Mar 13, 2006 1:24 am
by feyd
remove the limit and change the selection to a count()
Posted: Mon Mar 13, 2006 1:27 am
by jaylin
but, there are huge amount of record. so, i have to use limit. but, also, i have to know the total records count for the specific criteria. how can i do that? also, i dun want to execute 2 queries.
Posted: Mon Mar 13, 2006 1:35 am
by feyd
No way around it really.
Posted: Mon Mar 13, 2006 9:42 am
by ody
I think I understand you (but proberly not), how about something like this?
Code: Select all
select *, (select count(*) from table0) as count from table0 limit 0, 10;
Offcourse change table to whatever your table name it.
Posted: Mon Mar 13, 2006 9:46 am
by Chris Corbyn
Not likely that you're running an older version but AFAIK sub-queries will only work in MySQL 4.1+ if that gives you any bother
