RE: [PHP] Limit the amount of returns in a MySQL query

From: Date: Fri, 07 Feb 2003 21:00:08 +0000
Subject: RE: [PHP] Limit the amount of returns in a MySQL query
Groups: php.general 
Request: Send a blank email to php-general+get-134793@lists.php.net to get a copy of this message
select * from mailaddresses where id < 10 LIMIT 10; -----Original Message----- From: Daniel Page [mailto:dlp@dlpage.com] Sent: Friday, February 07, 2003 2:53 PM To: php-general@lists.php.net Subject: [PHP] Limit the amount of returns in a MySQL query 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#134793) next »