aeris130 Posted March 20, 2006 Share Posted March 20, 2006 Here's my query:[code]SELECT * FROM table WHERE column LIKE \"%$trimmed%\" AND approved='yes' ORDER BY number ASC[/code]"number", is a column that stores a certain number (VARCHAR 10, other then ID) that's unique. These numbers range from 1 to 999. The problem is, that the results are sorted based on the first digit, not the entire number.Say I have these numbers: 1, 2, 4, 8, 9, 25, 88, 106 and 305.The results get sorted like this:[code]110622530548889[/code]But I want to store them in the correct order (1, 2, 4, 8, 9, 25, 88, 106 and 305).How do I solve this? Quote Link to comment Share on other sites More sharing options...
ober Posted March 20, 2006 Share Posted March 20, 2006 If the values are truly numbers, change the datatype to int instead of varchar. Quote Link to comment Share on other sites More sharing options...
trq Posted March 20, 2006 Share Posted March 20, 2006 The filed needs to be of a numerical type like INT, not VARCHAR. Quote Link to comment 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.