Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
gnel2000
Forum Newbie
Posts: 16 Joined: Tue Jul 26, 2005 10:41 pm
Post
by gnel2000 » Fri Jun 30, 2006 11:24 pm
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?
duk
Forum Contributor
Posts: 199 Joined: Wed May 19, 2004 8:45 am
Location: London
Post
by duk » Sat Jul 01, 2006 5:21 am
ORDER bY ASC
have you try ??? not sure if works as you want...
gnel2000
Forum Newbie
Posts: 16 Joined: Tue Jul 26, 2005 10:41 pm
Post
by gnel2000 » Tue Jul 04, 2006 8:53 pm
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?
printf
Forum Contributor
Posts: 173 Joined: Wed Jan 12, 2005 5:24 pm
Post
by printf » Tue Jul 04, 2006 9:55 pm
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
gnel2000
Forum Newbie
Posts: 16 Joined: Tue Jul 26, 2005 10:41 pm
Post
by gnel2000 » Wed Jul 05, 2006 12:52 am
thanks printf , is working fine.
Thanks a lot.