Results 1 to 4 of 4
Thread: sorting issue
Feb 3, 2006, 13:21 #1
I'm running a query on a table that contains a column of type varchar. Here are some example row values for this column:
When I run a query that sorts by this column, I get them in this order:
What I need is for them to be sorted this way:
Anyone know why it sorts in this way? Should I be using something other than varchar?
Feb 3, 2006, 14:06 #2
Ok....... How do you make MySQL order that column like that, can you type the command for us?
Feb 3, 2006, 14:29 #3
SELECT * FROM members ORDER BY id_number ASC
It seems to be ignoring the leading zeros when it sorts.
Feb 3, 2006, 14:39 #4
- Join Date
- Jul 2005
- West Springfield, Massachusetts
- 113 Post(s)
- 1 Thread(s)
You may have to give the field the BINARY attribute to sort it correctly.
All string comparisons are case insensitive by default, with sort ordering determined by the current character set (ISO-8859-1 Latin1 by default). If you don't like this, you should declare your columns with the BINARY attribute or use the BINARY cast, which causes comparisons to be done according to the ASCII order used on the MySQL server host.10 Rules for Driving Traffic Using Forums | Ultimate SEO Checklist
External links are nofollow
How to be a Great Online Community Member
Member of the Month for December 2013
Free SitePoint book - Thinking Web: Voices Of The Community
The 2013 SitePoint Awards - Nominations closed - Voting to begin soon
Introducing the new Code Review Forum