MySQL skip first 10 results

Mysql

Mysql Problem Overview


Is there a way in MySQL to have the first 10 result from a SELECT query skipped? I'd like it to work something like LIMIT.

Mysql Solutions


Solution 1 - Mysql

Use LIMIT with two parameters. For example, to return results 11-60 (where result 1 is the first row), use:

SELECT * FROM foo LIMIT 10, 50

For a solution to return all results, see Thomas' answer.

Solution 2 - Mysql

There is an OFFSET as well that should do the trick:

SELECT column FROM table
LIMIT 10 OFFSET 10

Solution 3 - Mysql

OFFSET is what you are looking for.

SELECT * FROM table LIMIT 10 OFFSET 10

Solution 4 - Mysql

From the manual:

> 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;

Obviously, you should replace 95 by 10. The large number they use is 2^64 - 1, by the way.

Solution 5 - Mysql

LIMIT allow you to skip any number of rows. It has two parameters, and first of them - how many rows to skip

Solution 6 - Mysql

select * from table where id not in (select id from table limit 10)

where id be the key in your table.

Solution 7 - Mysql

To skip first 10 rows use OFFSET 10, but LIMIT is also required,

If you want to get all the rows and only skip first 10 rows try using a big number like 999999999 or as per your choice

SELECT * FROM table LIMIT 999999 OFFSET 10

Solution 8 - Mysql

If your table has ordering by id, you could easily done by:

select * from table where id > 10

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrianView Question on Stackoverflow
Solution 1 - MysqlDominic RodgerView Answer on Stackoverflow
Solution 2 - MysqljamesaharveyView Answer on Stackoverflow
Solution 3 - Mysqluser258082View Answer on Stackoverflow
Solution 4 - MysqlThomasView Answer on Stackoverflow
Solution 5 - MysqlYour Common SenseView Answer on Stackoverflow
Solution 6 - MysqlmickeymoonView Answer on Stackoverflow
Solution 7 - MysqlVicky SalunkheView Answer on Stackoverflow
Solution 8 - MysqlBiswajit PaulView Answer on Stackoverflow