homepage Welcome to WebmasterWorld Guest from 54.211.97.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Need help in sorting mysql result
mysql result sort
aldwin



 
Msg#: 4580062 posted 2:05 am on Jun 1, 2013 (gmt 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

 

LifeinAsia

WebmasterWorld Administrator lifeinasia us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4580062 posted 2:10 am on Jun 1, 2013 (gmt 0)

If Type is only 0 or 1, you can use:
ORDER BY Type DESC, Name

aldwin



 
Msg#: 4580062 posted 2:23 am on Jun 1, 2013 (gmt 0)

that worked, thanks :)

phranque

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



 
Msg#: 4580062 posted 11:04 am on Jun 1, 2013 (gmt 0)

welcome to WebmasterWorld, aldwin!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved