Welcome to WebmasterWorld Guest from 54.145.144.101

Forum Moderators: open

Message Too Old, No Replies

Help with ORDER BY statement

   
3:05 am on Jun 18, 2007 (gmt 0)

10+ Year Member



For some reason the ORDER BY clause sort mode is case sensitive, that is, it "sorts" uppercase fields firts and lower case fields at the end.

Is there some way to specify a case insensitive sorting? Thanks!

6:24 am on Jun 18, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



you didn't really state which database or field type you are using, but in general you can try folding all column values to one case such as:
SELECT text_column FROM some_table ORDER BY UPPER(text_column)
1:56 pm on Jun 18, 2007 (gmt 0)

5+ Year Member



This can be very slow on big tables because mysql will have to loop through each record uppercasing it. In this case you may consider saving uppercased values in separate indexed field and use it in where clause.

But above suggestions should be ok if table has not much data.

9:17 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



Thanks, I think that should work because table won´t be big initially, abnd the default sort mode will be date instead of name.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month