Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All rows after the nth row?

Tags:

mysql

If I specify a number, say 5, what query will give me all the rows after the 5th row? Like,

SELECT * FROM table WHERE 1=1;

only I want it to exclude the top 5. Thanks.

like image 967
mathon12 Avatar asked Sep 03 '25 16:09

mathon12


2 Answers

Use the limit with a very high number as the second argument.

select * from myTable limit 5,18446744073709551615;

From MySQL Docs:

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;

BTW: You don't need WHERE 1=1. It doesn't add any value to the query, just clutter.

like image 117
Asaph Avatar answered Sep 05 '25 07:09

Asaph


SELECT * FROM table ORDER BY somecolumn LIMIT 5,1000

http://dev.mysql.com/doc/refman/5.1/en/select.html

[LIMIT {[offset,] row_count | row_count OFFSET offset}]
like image 21
gahooa Avatar answered Sep 05 '25 05:09

gahooa