使用SELECT从第x位开始查询MSQL以查找获胜者 [英] Query MSQL for winners, starting at xth place using SELECT

查看:137
本文介绍了使用SELECT从第x位开始查询MSQL以查找获胜者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的MySQL表Winners中,我列出了获胜的人.

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

我想做的是选择10名获奖者的名单.所以我现在是这样的:

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

这将返回前10名获奖者.

This returns the first 10 winners which is great.

但是如何使它(例如)返回10位获奖者,但从第20位开始呢?现在,我所能想到的就是取消限制,并以编程方式抽出我想要的10个获胜者.但是我敢肯定有一种更简单的方法.

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.

推荐答案

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

或者只是

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

这篇关于使用SELECT从第x位开始查询MSQL以查找获胜者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆