SELECT * FROM highscore ORDER BY score
This code always sorts my values for lowest to highest but I want them from the highest to the lowest.
Actually I have two sets of data in my table and I always get:
0
235235
But I need it to be like this:
235235
0
I have already tried:
SELECT * FROM highscore ORDER BY CAST(score AS int)
But that gave me a syntax-error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT)' at line 1"
In my table score is set as int(100).
Does anybody have a solution how I could sort them like that? There will never be negative or non-int values.
You have to use
SELECT * FROM highscore ORDER BY score DESC
There also exists
SELECT * FROM highscore ORDER BY score ASC
, but this is the default behaviour.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With