RaxinII
RaxinII

Reputation: 11

Sort MySQL in Human

here's the code:

$sql_namesResult = mysql_query("SELECT name  FROM `scrimaprovedlist` ORDER BY `scrimaprovedlist`.`eorank`");

eo rank is a NUMERICAL value for a rank (general, colonel, ect).

The problem is, when i set myself for 1, i am the top, but comes rank 10, instead of rank 2. how do i edit this to make it show in order:

1
2
3
10
20
30

I'm currently using "rank" instead of "eorank" because it is easier. but the problem is i have to manually edit the ranks over and over again so that they show in the correct order. Any ideas?

Viewable at http://www.thexcrew.com/modules.php?name=Roster

Upvotes: 0

Views: 279

Answers (2)

Joe Phillips
Joe Phillips

Reputation: 51120

ORDER BY CAST(scrimaprovedlist.eorank AS INTEGER)

Your ranks are strings instead of integers so they will be sorted as a string unless you cast or convert them to integers which I've done above

Upvotes: 5

RaxinII
RaxinII

Reputation: 11

figured out a way, i changed my Numerical value to an alphabetical value. using only 17 ranks, i am able to substitute #'s for letters. thanks for the help anyway :)

Upvotes: 0

Related Questions