You are here: Re: Large query results - Limiting the data, but still knowing the full row count - How? « PHP SQL « IT news, forums, messages
Re: Large query results - Limiting the data, but still knowing the full row count - How?

Posted by Tom on 06/20/07 17:52

On Wed, 13 Jun 2007 09:00:11 GMT, cluthz wrote...
>
>Hi there,
>
>I have query which returns to many results to handle (therefore to be
>displayed screen at one time and to be transferred from the server).
>
>I therefore want to create a search results screen which displays a limited
>subset of query results and the user of the application can control which
>subset of results are displayed (e.g. say there are 10000 matching results,
>the user can see results 1-500, and move on in batches of 500).
>
>The only thing is, to get the amount of rows I still have to run a very
>similar (and therefore big) MySQL query as if I was getting all 10000
>results, just to find out how many results there actually are.
>
>So am I right in thinking this is the way to go about it. Therefore I run
>the query once but only ask for a count of results to be returned. This
>gives me the total amount of matches.
>Then I run the query again, this time returning all the fields information,
>but this time I use LIMIT to restrict the actual results.
>
>I hope this question makes sense and thanks in advance for any input.
>
>
>


If you use "LIMIT" on your SQL query, then the total count would be limited to
the range you pick. You might need to run a couple of queries, one to get the
total count, and the other to get the results with a limit to control the range
you need to output.

Tom
--
Newsguy.com - Unlimited Accounts
Now with 32 concurrent connections

 

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

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