Omit the first 5 rows?
I want to SELECT all rows except for the first 5 rows in a table.
How do I do that?
Why can't I just type
$query = "SELECT *
FROM ages
OFFSET 5
开发者_开发知识库ORDER BY id ASC";
SELECT * FROM tbl LIMIT 5,18446744073709551615;
from http://dev.mysql.com/doc/refman/5.0/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 Oracle:
select name, price from items where rownum > 5
Here's a solution using variables - just add your order by clause and you should be set.
set @n=-1
select * from TABLE where (@n:=@n+1) >= 5;
I just typed:
$query = "SELECT *
FROM ages
LIMIT 100
OFFSET 10";
Why couldn't anybody give me such an easy answer? :)
精彩评论