SELECT and ORDER BY.
A basic query could be built as:
You can order ascending or descending using ASC or DESC: "(...) ORDER BY someColumn ASC" or "(...) ORDER BY someColumn DESC"
You can limit the results using "LIMIT" (in any select query):
For your situation, I'm assuming your table looks like this:
So if you'd want to show a top 3 (top ranking) based on their score, showing the highest score first you'd have to order by (ascending) column score in this case:
Output for this query then would be:
Note that queries may be more (way more) complex than this. However there's alot of documentation for that online. If you have any questions, use a search engine first now that you know the basics of that what you're looking for, enough information is already on the internet.
A basic query could be built as:
Code:
SELECT someData FROM someTable ORDER BY someColum;You can limit the results using "LIMIT" (in any select query):
Code:
SELECT * FROM someTable LIMIT 5; -- Would show no more than 5 results, even if there are more resultsFor your situation, I'm assuming your table looks like this:
Code:
-- table "teams" --
[id] [name] [score]
1 groves 50
2 ballaz 24
3 metalheadz 85
4 poo 0
5 a-team 12
6 fez 104
7 zepheads 73So if you'd want to show a top 3 (top ranking) based on their score, showing the highest score first you'd have to order by (ascending) column score in this case:
Code:
SELECT name, score FROM teams ORDER BY score ASC LIMIT 3;Code:
[name] [score]
fez 104
metalheadz 85
zepheads 73Note that queries may be more (way more) complex than this. However there's alot of documentation for that online. If you have any questions, use a search engine first now that you know the basics of that what you're looking for, enough information is already on the internet.

