从排序列表的中间选择结果?

发布于 2024-09-10 12:05:14 字数 74 浏览 1 评论 0原文

我有一个包含 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

究竟谁懂我的在乎 2024-09-17 12:05:14
SELECT * 
FROM table
ORDER BY somecolumn
LIMIT 10,40 

来自 MySQL 手册:
LIMIT 子句可用于限制 SELECT 语句返回的行数。 LIMIT 接受一个或两个数字参数,它们必须都是非负整数常量(使用准备好的语句时除外)。
使用两个参数,第一个参数指定要返回的第一行的偏移量,第二个参数指定要返回的最大行数。初始行的偏移量为 0(不是 1)

SELECT * 
FROM table
ORDER BY somecolumn
LIMIT 10,40 

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)

坦然微笑 2024-09-17 12:05:14

LIMIT 语法 包含一个偏移值,因此您可以使用:

LIMIT 10, 40

...获取第 11 - 50 行,因为初始偏移行为零(不是 1)。

The LIMIT syntax includes an offset value, so you'd use:

LIMIT 10, 40

...to get rows 11 - 50, because the initial offset row is zero (not 1).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文