MySQL limit range
52,991
Solution 1
You should use:
SELECT name FROM mydb ORDER BY score DESC LIMIT 10,10;
http://dev.mysql.com/doc/refman/5.5/en/select.html
The two arguments 10,10 are (Offset, Limit) so this will retrieve rows 11-20.
9,11 Would be required to grab the 10th - 20th rank.
Solution 2
Use offset
to clarify the query.
SELECT name FROM mydb ORDER BY score DESC LIMIT 10 OFFSET 10
Solution 3
Limit has also an offset parameter
SELECT name FROM mydb ORDER BY score DESC LIMIT 10,10
Solution 4
SET @rank = 0;
SELECT rank, name, score
FROM (
SELECT @rank := @rank +1 AS rank, name, score
FROM mydb
ORDER BY score DESC
LIMIT 100
) X
WHERE rank >= 10;
Solution 5
you may use offset
SELECT name FROM mydb ORDER BY score DESC LIMIT 10 OFFSET 10
here, offset indicates that from where next 10 data will show.
you may also use below :
SELECT name FROM mydb ORDER BY score DESC LIMIT 10, 10
Author by
theHack
Updated on November 07, 2020Comments
-
theHack over 3 years
SELECT name FROM mydb ORDER BY score DESC LIMIT 10;
The query above will return the first 10 ranks.
How to modify the
LIMIT
, or maybe is there another syntax to query the 10th rank through the 20th rank?