You are here: Re: Need to substitute #where# with $where « PHP Programming Language « IT news, forums, messages
Re: Need to substitute #where# with $where

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация