Reputation: 43
How to start from a certain row and end in a certain row in mysql ?
Example :
row 1 - Mike
row 2 - ayman
row 3 - kayla ---> i want to start from here
row 4 - polat
row 5 - ninety
row 6 - Okamou
row 7 - Sakura
row 8 - kall ---> i want to end here
row 9 - kopa
row 10 - Traas
what i'm using is:
Select name, number, id from usernames_table LIMIT 3,8
This is just an example, In my real application i want to start from row number 2000 and end in row 6000 which is not the end of the table.
I used LIMIT starthere, endhere
but it gives me some extra rows i don't know why?
Please help ?
Upvotes: 1
Views: 1180
Reputation: 23892
You are using the limit
incorrectly. This:
Select name, number, id from usernames_table LIMIT 3,8
says to start at row 4 and end after 8 rows have been selected.
Try:
Select name, number, id from usernames_table LIMIT 2,6
This says start after row 2, and return 6 rows (so 3-8).
Further information: http://dev.mysql.com/doc/refman/5.7/en/select.html
... or for your real application:
Select name, number, id from usernames_table LIMIT 1999,4000
which says start at 2000 and return 4000 rows (so end at 6000, assuming rows weren't deleted..).
Upvotes: 1