Results 1 to 4 of 4
Thread: sorting issue
Feb 3, 2006, 14: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, 15:06 #2
Ok....... How do you make MySQL order that column like that, can you type the command for us?
Feb 3, 2006, 15:29 #3
SELECT * FROM members ORDER BY id_number ASC
It seems to be ignoring the leading zeros when it sorts.
Feb 3, 2006, 15:39 #4
- Join Date
- Jul 2005
- West Springfield, Massachusetts
- 187 Post(s)
- 2 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.