View Single Post
  #2 (permalink)  
Old 09-02-2006, 01:00 AM
ben ben is offline
Administrator
 
Join Date: Mar 2007
Posts: 93
ben has disabled reputation
Default MySQL answer. Re: How do I select the highest 20 to 30 values?

The idea is always the same and can be adjusted to select any position. First you have to order the query and select the first 19 values (Let's say we want the 20th to 30th highest score in a competition). Then exclude the first 19 rows, and return the next 10 rows. This will give you the 20th to 30th highest score.

[sql]
SELECT * FROM competition WHERE id NOT IN (SELECT id FROM competition ORDER BY score DESC LIMIT 19) ORDER BY score DESC LIMIT 10
[/sql]
Reply With Quote