tags:

views:

32

answers:

1

Is there a value that used with a LIMIT clause means nothing or no limit?

I'd expected that 0 would be that value but it obviously isn't:

SELECT * FROM items LIMIT 0 -- returns 0 rows
+2  A: 

Use a value far outside the number of records you're actually retrieving:

LIMIT 0, 18446744073709551615

Quote:

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter.

OMG Ponies
I was hoping a more elegant approach existed.
Emanuil
Is the `0, ` part necessary? I'd expect that just `LIMIT 18446744073709551615` would work the same way.
Emanuil
@Emanuil: Zero is the notation for accessing the first element in an array - very common in programming. You can omit the first parameter if you want the records to limit based on the first position.
OMG Ponies