Re: Looping through
| From: | Tim Paul | Date: | Tue, 07 Nov 2000 21:01:23 +0000 |
| Subject: | Re: Looping through | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4290@lists.php.net to get a copy of this message | ||
Jayme,
To retrieve only the first n records of a result set, use the LIMIT clause
in your query, i.e. SELECT * FROM table_name LIMIT n.
To retrieve the next n rows from the result set, use the LIMIT clause again,
this time with an extra comma: SELECT * from table_name LIMIT m, n. This
tells MySQL to retrieve the n records starting from record number m in the
result set.
(Above from http://www.bitbybit.dk/mysqlfaq/faq.html)
Example:
// -- get first 10 results
(SELECT * FROM your_db_name LIMIT 10)
// -- get results 11-20
(SELECT * FROM your_db_name LIMIT 10, 10)
// -- get results 21-30
(SELECT * FROM your_db_name LIMIT 20, 10)
// -- etc.
Cheers, Tim
> From: "Jayme Jeffman Filho" <jjeffmanweb@conex.com.br>
>
> Another question is : how to deal with "limit" ? If I have many records that
> match the query but I'm using limit for performance optimization, how can I
> get the next five records that match the query and so on ? How can I put
> this in a "while" style structure like "spiders" do when searching pages ?
>
> Jayme.
>
> http://www.conex.com.br/jjeffman
--
H E C K L E R A S S O C I A T E S
communication design and marketing
tim@hecklerassoc.com