问题
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