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
- 198 Post(s)
- 3 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.Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse