MYSQL : Ordering by Numbers
I came across this post today in search of being able to order a varcahr field by the true number value. When running a normal “ORDER BY column_name”, your data will be returned to you in an order of the 0 to 9 based off the first character. I found a quick and simple solution – wrap your column_name with the absolute value, ABS(), function.
Quick Example
$query = “SELECT * FROM table_name ORDER BY ABS(retail_price) DESC “;
In this example, I selected all of the data from my table and ordered it by the retail_price column, descending from 9-0.
And here is the link for an in depth walk-through of this - http://www.lost-in-code.com/programming/mysql/mysql-order-by-numbers/
