Welcome to WebmasterWorld Guest from 54.161.128.52

Forum Moderators: open

Message Too Old, No Replies

Need help in sorting mysql result

mysql result sort

     
2:05 am on Jun 1, 2013 (gmt 0)

New User

joined:May 25, 2013
posts: 7
votes: 0


i have this table:

+--------+------------+
| ID | name | type
+--------+------------+
| 1 | Alex | 0
| 2 | John | 1
| 3 | Gerry | 0
| 4 | Mark | 0
| 5 | Dave | 1
| 6 | Blake | 0
+--------+------------+

how can i get an output that is ordered alphabetically, but also displaying those with TYPE==1 first?

needed output:
Dave
John
Alex
Blake
Gerry
Mark
2:10 am on June 1, 2013 (gmt 0)

Moderator from US 

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

joined:Dec 10, 2005
posts:5634
votes: 52


If Type is only 0 or 1, you can use:
ORDER BY Type DESC, Name
2:23 am on June 1, 2013 (gmt 0)

New User

joined:May 25, 2013
posts: 7
votes: 0


that worked, thanks :)
11:04 am on June 1, 2013 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10595
votes: 22


welcome to WebmasterWorld, aldwin!