How to Select First Last or Range of Records in MySQL Table

When using MySQL, and wanting to retrieve the first n records from a table, one can use the LIMIT function. It can also be used to grab a range of records, not just a series starting with the first record. Use as follows:

SELECT * FROM yourtable LIMIT yourlowlimit,yourhighlimit;

This will return all rows between the number yourlowlimit and yourhighlimit inclusive.

e.g. SELECT FROM users LIMIT 20,50
will return the rows 20, 21, 22,…, 49, 50

Thanks to dmxzone.com

Posted under Freeware, MySQL

This post was written by Content Curator on November 16, 2009

Tags: , , , , , , , , , ,