Query MSQL for winners, starting at xth place using SELECT

最后都变了- 提交于 2019-12-11 01:55:53

问题


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.


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/2478841/query-msql-for-winners-starting-at-xth-place-using-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!