Thread: total row count for selects with a limit

total row count for selects with a limit

From
"Peter"
Date:
Hi there,
 
what seems to be the best way of getting the total row number on select queries with a limit on them?
 
What I am currently thinking of doing is building select queries dynamically and wrapping all selected fields into the count() function without the limit
 
somthing like:
 
select a,b,c from table limit 10
 
and for total count
 
select count(a,b,c) from table
 
and a function to build the select query with parameters such as
 
function build_select($table, $cols=array(), $limit, $orderby, $where) { ... }
 
I am going in the right direction? Instead of one query I need 2 is there a way of making it just one query?
 
thanks for any help
 
regards, Peter