从排序列表的中间选择结果?
我有一个包含 300 行的简单表,在对它们进行排序后,我想选择第 11-50 行。我是否要限制 50 行并以某种方式删除前 10 行?
I've got a simple table with 300 rows, and after ordering them I want to select rows 11-50. Do I limit by 50 and remove the top 10 rows somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 MySQL 手册:
LIMIT 子句可用于限制 SELECT 语句返回的行数。 LIMIT 接受一个或两个数字参数,它们必须都是非负整数常量(使用准备好的语句时除外)。
使用两个参数,第一个参数指定要返回的第一行的偏移量,第二个参数指定要返回的最大行数。初始行的偏移量为 0(不是 1)
From MySQL's manual:
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1)
LIMIT 语法 包含一个偏移值,因此您可以使用:
...获取第 11 - 50 行,因为初始偏移行为零(不是 1)。
The LIMIT syntax includes an offset value, so you'd use:
...to get rows 11 - 50, because the initial offset row is zero (not 1).