Re: limit in query
| From: | Matt Schroebel | Date: | Wed, 13 Dec 2000 14:55:21 +0000 |
| Subject: | Re: limit in query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30094@lists.php.net to get a copy of this message | ||
You use LIMIT to reduce the number of rows returned by a query to the database. Say you have a
database of products containing 2,000 entries. You probably would not want to display the entire
result set on one page. So say you want to display 20 products on a page. To do this, you'd
use a sql statement like:
SELECT * from products LIMIT 0,20
for the first page. The two parameters indicate the starting row of the total result set, and
maximum records to return. So the 0 indicates the first row and 20 indicates you want no more than
20 rows. On subsequent pages, you change the start value to the next increment like:
SELECT * from products LIMIT 20,20
Typically you would use variables for the start,limit values, and not hard code them as I did
(which is for clarity).
>>> "Jacky" <jacky@activelifestyle.com> 12/13 6:02 PM >>>
Hi all,
Can any one tell me what it means when you put LIMIT function on a query? I am a newbie and went to
search in php.net but could not find it yet.
Jack
jacky@activelifestyle.com
"Power is nothing without control