พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com
Databases help / Using LIMIT with SELECT
Nick
Nick
Fri 3 Jun 2005 13:30:43
Hi All,

I have a problem using the LIMIT statement in MySQL. Basically I want to limit results to a number such as 200. However, this works fine except it returns the *first* 200 records it finds. What I want is the *last* 200 records because I need to examine the latest records.

here's an example of how the query looks now:

SELECT recordid FROM allRecords WHERE userID = $uID ORDER BY recordid LIMIT 0, 200

What do I need to change/add to make it pull the latest records and not the first 200?

Thanks,
Nick
Administrator
Administrator
Fri 3 Jun 2005 13:37:39

In your SELECT query you could use DESC for sorting lastest record like this

SELECT recordid FROM allRecords WHERE userID = $uID ORDER BY recordid DESC LIMIT 200

Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login