|
Posted by Marcin Dobrucki on 11/18/09 11:42
comp.lang.php wrote:
>>>"SELECT id, first_name, last_name, (SELECT count(id) #where#) as
>>>paginate_total, email, address, city, state, zip, phone FROM person
>>>$where "
>>>
>>>You want "#where#" inside the subselect substituted with $where
>>
>> So basically you are selecting "id, first_name, last_name ..." and
>>count of the returned results? Why not just ask the DB how many rows it
>>returned?
> Because the resultset will have, for example, only 20 rows while the
> entire table might have 20,000 rows. I must show how many total
> records exist, all the while, only display a unit of 20.
But your original post said:
"How do I substitute #where# with $where?"
So if your count-select is also governed by the same "where"
statement, then your count will be that of the selected set.
There are also simpler ways (IMHO) to get the total, eg, just run a
second separate select query with only count(id).
/m
Navigation:
[Reply to this message]
|