使用 SELECT 从第 x 位开始查询 MSQL 获胜者

发布于 2024-08-26 01:02:58 字数 297 浏览 3 评论 0原文

在我的 MySQL 表 Winners 中,我有一个获胜者的列表。

我想做的是选出 10 名获奖者的名单。所以我现在所拥有的是:

SELECT name FROM Winners ORDER BY points DESC LIMIT 10

这将返回前 10 名获奖者,这非常棒。

但是我怎样才能让它(例如)返回 10 个获胜者,但从第 20 位开始呢?现在我能想到的就是取消 LIMIT 并以编程方式选出我想要的 10 名获胜者。但我确信有更简单的方法。

In my MySQL table Winners, I have a list of people who have won.

What I'd like to do is select a list of the names of 10 winners. So what I have right now is this:

SELECT name FROM Winners ORDER BY points DESC LIMIT 10

This returns the first 10 winners which is great.

But how can I make it (for example) return 10 winners, but starting at 20th place? Right now all I can think of is removing the LIMIT and programatically pulling out the 10 winners I want. But I'm sure there's an easier way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

尐籹人 2024-09-02 01:02:58
SELECT  name
FROM    Winners
ORDER BY
        points DESC
LIMIT 10 OFFSET 20 

或者只是

SELECT  name
FROM    Winners
ORDER BY
        points DESC
LIMIT 20, 10
SELECT  name
FROM    Winners
ORDER BY
        points DESC
LIMIT 10 OFFSET 20 

or just

SELECT  name
FROM    Winners
ORDER BY
        points DESC
LIMIT 20, 10
停滞 2024-09-02 01:02:58
SELECT name FROM Winners ORDER BY points DESC LIMIT 20, 10
SELECT name FROM Winners ORDER BY points DESC LIMIT 20, 10
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文