Page 1 of 1

Order By using characters.. [Solved]

Posted: Thu May 05, 2005 1:08 pm
by waskelton4
Hello,

I have a query that is returning rows that need to be ordered by an ID that holds one or two characters.

the IDs are A, B, C, D,.... X, Y, Z, AA, BB, CC ...

Is there a way i can order this in the order shown above without creating another table and using numerical keys to associate those values. Currently the order is A, AA, B, BB, C, CC.....

Thanks for any help!
Will

Posted: Thu May 05, 2005 1:22 pm
by timvw
If you are using MySQL, you could try something like:

Code: Select all

SELECT CHAR_LENGTH(name) AS length, *
FROM table
ORDER BY length ASC, name DESC

Order By using characters. [solved]

Posted: Thu May 05, 2005 1:50 pm
by waskelton4
Perfect..

Thanks!!