Limit the amount of returns in a MySQL query
| From: | Daniel Page | Date: | Fri, 07 Feb 2003 20:52:57 +0000 |
| Subject: | Limit the amount of returns in a MySQL query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-134792@lists.php.net to get a copy of this message | ||
Hi All,
Imagine I have a giant database table tracking email addresses (I don't but
it is the first example that jumps to mind after my recent antispam
campaign!).
If i do a
select * from mailaddresses;
I will get all of the table.
If i do a
select * from mailaddresses where id < 10;
I will get all the records where the id is less than 10...
The problem is that I want 10 records, period, so if id is not a primary
key, I could have 60 records that match... or if it is a P.K., but I delete
2 to 8, it will only return 2 records (1 and 9...)
How can I structure the query to only return only 10 records ? the idea
being able to construct a query where if there are more than 10 (or x)
results on a page, you click on a link 'page 2' and so on, and the next
query will return the next 10 (or x) records...
Cheers,
Daniel