tags:

views:

32

answers:

2

I've got a simple table with 300 rows, and after ordering them I want to select rows 11-50. Do I limit by 50 and remove the top 10 rows somehow?

+3  A: 

The LIMIT syntax includes an offset value, so you'd use:

LIMIT 10, 40

...to get rows 11 - 50, because the initial offset row is zero (not 1).

OMG Ponies
+3  A: 
SELECT * 
FROM table
ORDER BY somecolumn
LIMIT 10,40 

From MySQL's manual:
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1)

Saggi Malachi