Tim Sadvak
Tim Sadvak

Reputation: 101

MySQL SELECT from the number of count

How will be possible to make SELECT from the 11th number of count? I mean start SELECT from 11th row instead of 1st.

Upvotes: 0

Views: 110

Answers (2)

Allen King
Allen King

Reputation: 2516

Try this if you want no limit only offset, else set a limit (number of max rows to be returned from offset row)

Select * from mytable limit 18446744073709551615 offset 10;

Upvotes: 1

Dai
Dai

Reputation: 155085

SELECT
    *
FROM
    your_table
ORDER BY
    date_time_added
LIMIT 10 OFFSET 10

The LIMIT [offset,] count OFFSET [offset] clause has a few forms:

LIMIT 10          -- Returns 10 rows with ordinal range 0-9

LIMIT 5, 10       -- Returns 10 rows with ordinal range 5-14

LIMIT 10 OFFSET 5 -- The same as LIMIT 5, 10

You must have an ORDER BY clause to make the LIMIT OFFSET clause meaningful - if no ordering is defined then the relative order of rows is meaningless.

If you don't want a LIMIT value (i.e. return all rows after an offset), then MySQL requires you to specify a very large number for the LIMIT ( Mysql Offset Infinite rows )

https://dev.mysql.com/doc/refman/5.7/en/select.html

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. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM tbl LIMIT 95,18446744073709551615;

In your case:

SELECT
    *
FROM
    your_table
ORDER BY
    date_time_added
LIMIT 18446744073709551615 OFFSET 5

Upvotes: 0

Related Questions