andyhajime Posted March 9, 2010 Share Posted March 9, 2010 Hey everyone... I'm really stuck. Need help. On mysql_query script (default mode) $FIND = mysql_query("SELECT * FROM listdata WHERE listing_status = '193'"); The above line result these numbers below. - 50.00 - 1200.20 - 46.86 - 843.20 - 10 - 510000 When I add ORDER BY number DESC, it results this which is totally wrong. I've notice it sorted out based on the first digit instead of as a whole number. - 843.20 - 510000 - 50.00 - 46.86 - 1200.20 - 10 The correct result I want is this - 510000 - 1200.20 - 843.20 - 50.00 - 46.86 - 10 Originally on the phpmyadmin table, the data is stored under the type "TEXT". Tried "VARCHAR(255)", still don't work. I want to change it to "INT(255)" since I learned that Interger are for numbers but if I changed it, I might risk the data too cause there's decimals in it. Furthermore I'm working on a LIVE website, so have to be very careful. Any ideas? please help. Quote Link to comment https://forums.phpfreaks.com/topic/194607-need-help-mysql-sort-numbers-desc/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 9, 2010 Share Posted March 9, 2010 Furthermore I'm working on a LIVE website, so have to be very careful. You would test and prove any changes on an off line copy of the site/database running on a development system first. You would also have a known good backup copy of the live database before you implement the actual changes on line. What do these numbers represent? What are the expected range of values? Also, INT(11) is the largest integer (you could use a BIGINT if you were only dealing with integer values), but you are correct that using an INT data type would drop the decimal parts. There are FLOAT and DECIMAL data types that would be the correct choice for storing decimal values. Quote Link to comment https://forums.phpfreaks.com/topic/194607-need-help-mysql-sort-numbers-desc/#findComment-1023517 Share on other sites More sharing options...
andyhajime Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks... used decimals. It works. Noted about the backup, which I normally did. Quote Link to comment https://forums.phpfreaks.com/topic/194607-need-help-mysql-sort-numbers-desc/#findComment-1023531 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.