I am wanting to order games on my website in order of the highest rated. My database is something like this:
Game.....Rating.....Number of Votes
game1....4...........7
game2....5...........1
game3....2...........83
game4....5...........7
But if I order by rating game2 would come before game4 but I would like game4 to come before game2 because it is still rated 5/5 but has had more votes. I have tried a few different ways to do this but can't seem to figure it out? I am currently using "ORDER BY Rating DESC".
Thanks alot.
Tom.
Ordering mySQL results by two fields
Moderator: General Moderators
Re: Ordering mySQL results by two fields
I guess you didn't know you can sort by multiple fields?
It'll sort those rated best first, but of those with the same rating ones with more votes have precedence.
Code: Select all
...ORDER BY Rating DESC, Number of Votes DESCRe: Ordering mySQL results by two fields
Thanks alot got it working perfect.