ERuiz Posted January 1, 2007 Share Posted January 1, 2007 I am running the following query:SELECT * FROM pirep ORDER BY LandingVS ASC LIMIT 20The problem is that the field LandingVS contains numbers such as these:-231.45-191.92-234.22-47.22-82.11The PROPER output should be:-47.22-82.11-191.92-231.45-234.22The query above, is outputting this:-191.92-231.45-234.22-47.22-82.11As you can see, it is reading each number from left to right, when deciding to do the order by. I need it to start from right to left, so that the true ASC can take place.Thanks for any help...ERuiz Link to comment https://forums.phpfreaks.com/topic/32432-solved-need-help-with-order-by-and-asc-command/ Share on other sites More sharing options...
chronister Posted January 1, 2007 Share Posted January 1, 2007 If your datatype is float, it will sort properly. You probably have it set to varchar.I created a new table and inserted the values you gave and then ran the query[code]SELECT *FROM `test`ORDER BY DATA ASC[/code]It returned[code]-234.22-231.45-191.92-82.11-47.22[/code]Data types really do matter. They tell MySql how to handle the data. Varchar sorts by the first letter/ number.... float tells it that the data is a floating point integer thereby sorting properly Link to comment https://forums.phpfreaks.com/topic/32432-solved-need-help-with-order-by-and-asc-command/#findComment-150697 Share on other sites More sharing options...
ERuiz Posted January 1, 2007 Author Share Posted January 1, 2007 That worked PERFECTLY!!! THANKS!!! Happy new year! :D Link to comment https://forums.phpfreaks.com/topic/32432-solved-need-help-with-order-by-and-asc-command/#findComment-150702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.