xyn Posted July 15, 2006 Share Posted July 15, 2006 Hi,I'm not sure if this is right so i tohught i'd get some advice from it. I want to search my members databse and list them in a table, Which has been done. But i want to list them in a particular order. I want to order them like:rank(admin, super-mod, mod) and then the members by usernames [b]ASC[/b]ending.is this right:$sql = mysql_query("SELECT user,rank,rep,mem_mail FROM accounts ORDER BY rank(admin,super-mod,mod),user ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/14670-mysql-order-by/ Share on other sites More sharing options...
hvle Posted July 15, 2006 Share Posted July 15, 2006 you can run the query and try it out. don't worry this query does not mess up your database. Quote Link to comment https://forums.phpfreaks.com/topic/14670-mysql-order-by/#findComment-58489 Share on other sites More sharing options...
Barand Posted July 15, 2006 Share Posted July 15, 2006 If that fails you can try[code]SELECT user,rank,rep,mem_mail,CASE WHEN rank='admin' THEN 1 WHEN rank='super-mod' THEN 2 ELSE 3 END as ranksort FROM accounts ORDER BY ranksort,user");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14670-mysql-order-by/#findComment-58520 Share on other sites More sharing options...
xyn Posted July 15, 2006 Author Share Posted July 15, 2006 alright :] thanks... Quote Link to comment https://forums.phpfreaks.com/topic/14670-mysql-order-by/#findComment-58572 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.