Reputation: 51
I am working on a simple project, I want to fetch the high score which is like high score on the top and lowest score in the bottom as the other games have score table.
I have done
SELECT * FROM [tablename] ORDER BY [Colname] DESC;
It made the high scorer on the top of the table and sort the table as descending order but php still fetching data ASCENEDING order . Which is not the high scorer.
1 id int(11) No None AUTO_INCREMENT Change Change Drop
2 addDate timestamp No None Change Change Drop Drop
3 name varchar(30) latin1_swedish_ci Yes NULL Change
4 score int(11) Yes NULL Change Change Drop Drop
5 image varchar(64) latin1_swedish_ci Yes NULL
Upvotes: 0
Views: 367
Reputation: 13931
Data type on that column must be wrong. Probably you are using one of text data types, and for example 11 is below 100 because text sorting works alphabetically character after character. First digits are the same, second digit in 100 is 0 (before 1)
Upvotes: 1