MySQL MySQL跳过前10个结果
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2827029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL skip first 10 results
提问by Brian
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 中有没有办法跳过 SELECT 查询的前 10 个结果?我希望它能像 LIMIT 一样工作。
回答by Dominic Rodger
Use LIMIT with two parameters. For example, to return results 11-60 (where result 1 is the first row), use:
使用带有两个参数的 LIMIT。例如,要返回结果 11-60(其中结果 1 是第一行),请使用:
SELECT * FROM foo LIMIT 10, 50
For a solution to return all results, see Thomas' answer.
有关返回所有结果的解决方案,请参阅Thomas 的回答。
回答by jamesaharvey
There is an OFFSET as well that should do the trick:
还有一个 OFFSET 应该可以解决问题:
SELECT column FROM table
LIMIT 10 OFFSET 10
回答by jamesaharvey
回答by Thomas
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;
要检索从某个偏移量到结果集末尾的所有行,您可以为第二个参数使用一些大数字。此语句检索从第 96 行到最后一行的所有行:
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.
显然,您应该替换95
为10
. 顺便说一下,他们使用的大数是 2^64 - 1。
回答by Your Common Sense
LIMIT allow you to skip any number of rows. It has twoparameters, and first of them - how many rows to skip
LIMIT 允许您跳过任意数量的行。它有两个参数,第一个参数 - 要跳过多少行
回答by mickeymoon
select * from table where id not in (select id from table limit 10)
where id
be the key in your table.
哪里id
是你桌子上的钥匙。
回答by Biswajit Paul
If your table has ordering by id, you could easily done by:
如果您的表按 id 排序,您可以通过以下方式轻松完成:
select * from table where id > 10