Page 1 of 1

Sorting record by alphabetic follow by number in one column

Posted: Fri Jun 30, 2006 11:24 pm
by gnel2000
hi there,

I have a column which contain numbers and alphabets, as i know mysql will sort the numbers first then follow by alphabet. I would like to sort the records by alphabetic then follow by numbers in ascending, can this be done in the query?

Posted: Sat Jul 01, 2006 5:21 am
by duk
ORDER bY ASC

have you try ??? not sure if works as you want...

Posted: Tue Jul 04, 2006 8:53 pm
by gnel2000
hm, not really...

let said i have the following record:

abc
123
567
456
def

if i use ASC, it will sorted in this way:
123
456
567

but i want it to be like this:
abc
def
123
456
567

any idea?

Posted: Tue Jul 04, 2006 9:55 pm
by printf

Code: Select all

SELECT my_column FROM my_table ORDER BY my_column+0, my_column;

reverse the ORDER to do it the other way around


pif

Posted: Wed Jul 05, 2006 12:52 am
by gnel2000
thanks printf , is working fine.

Thanks a lot.