homepage Welcome to WebmasterWorld Guest from 54.166.15.152
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
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:4580064
 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




msg:4580068
 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:4580072
 2:23 am on Jun 1, 2013 (gmt 0)

that worked, thanks :)

phranque




msg:4580123
 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