What I am trying to do here is to rank the results I am getting based on one column, but order them based on another column.
For instance, say I've got a table locations. I want to query it such that I get a rank based on the score, but I want it ordered by the location name. Is this even possible?
I am using MySQL
ranking or incrementing results
Moderator: General Moderators
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
ok lets say I have table locatoins
Now what I want to do is get a result ordered by LocName. I also want to know the score, but not the actual score, rather, the rank of the score, as if i was ordering by LocScore descending, which number it would be. So if there were three shops scoring 100, 100, and 95, their ranks would be 1, 1, an 2 respectivly. In essence I am trying to order by two different columns. I am afraid this may be unpossible, and I am trying to work out a way to do it by some sorting of the resulting arrays, but the size of them frightens me.
Code: Select all
LOCATIONS
LocID
LocName
LocScore