Page 1 of 1

[SOLVED] ORDER BY problem.

Posted: Wed Feb 16, 2005 6:53 pm
by Dale
Im using the

Code: Select all

ORDER BY
line in my code but for some reason, its only sorting the numbers in my databse by there first number.

eg;
My Code:

Code: Select all

$sql = "SELECT * FROM top_mybb_sites WHERE approved = 1 ORDER BY posts ASC";
Shows:

142233
152
17
2342
210
24
35
486
42

How do i get it to sort in numerical order? (eg; 17, 24, 35, 42, ect...)

Posted: Wed Feb 16, 2005 7:04 pm
by feyd
obviously you aren't storing them in integer fields.. you should be able to cast the field to integer and sort by the result.

Posted: Wed Feb 16, 2005 7:14 pm
by Dale
Ah thanks it worked. :)