Possible Duplicate:
Mysql Offset Infinite rows
Is it possible to specify a query in MySQL with a 'offset' but without a 'limit'. For example:
SELECT * FROM countries OFFSET 2
Fails, but:
SELECT * FROM COUNTRIES LIMIT 8 OFFSET 2
Works fine. I'd like to just specify the offset. Thanks!
Basically, no. Limit must be supplied.
The limit option allows you to limit the number of rows returned from a query, while offset allows you to omit a specified number of rows before the beginning of the result set. Using both limit and offset skips both rows as well as limit the rows returned.
MySQL Offset is used to specify from which row we want the data to retrieve. To be precise, specify which row to start retrieving from. Offset is used along with the LIMIT. Here, LIMIT is nothing but to restrict the number of rows from the output.
To get only the specified rows from the table, MySQL uses the LIMIT clause, whereas SQL uses the TOP clause, and Oracle uses the ROWNUM clause with the SELECT statement.
Basically, no. Limit must be supplied. See this SO question for a solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With