Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get a specified number of rows to be returned?

Status
Not open for further replies.

Inandjo

Programmer
Dec 7, 2001
46
FR
hi ,

i am writing a pager for an application, and i would like to know what SQL command i have to execute to have say row x to y in a result set.
Thanx

La faim justifie les moyens!
 
select * from table limit 10,100

return 100 rows from starting at row 10

(or was it the other way around??)
 
hos2:
You have it right.


Inandjo:
The LIMIT clause, as hos2 has said, can return a number of rows, starting with a given position. But keep in mind that MySQL starts counting rows from 0.

So something like "LIMIT 10, 5" will return the 11th through 15th records. Think of the first number as being the number of records to skip.

Also, "LIMIT 0, 10" ("return 10 rows, skipping 0 rows" or "return the first 10 rows") can be abbreviated "LIMIT 10".

The LIMIT clause is documented as part of the SELECT query documentation:
Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top