jaymc Posted January 16, 2007 Share Posted January 16, 2007 I have the following fields in a DBgroupgenderusernameI want the data to be ordered by the group, then by gender, then by username AZMy aim is to have people in the highest group at the top but for people in the same group I want to have them orded by gender and then by username..ORDER BY `group`, `gender`, `username` ASC doesnt work.. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 16, 2007 Share Posted January 16, 2007 It definitely does "work"... give an example. Quote Link to comment Share on other sites More sharing options...
jaymc Posted January 16, 2007 Author Share Posted January 16, 2007 $query='SELECT * FROM '.$prefix."_online WHERE ($timestamp-rtime)<20 ORDER BY `group`, `gender`, `username` DESC"; Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 16, 2007 Share Posted January 16, 2007 Try this:$query='SELECT * FROM '.$prefix."_online WHERE ($timestamp-rtime)<20 ORDER BY `group` DESC, `gender` DESC, `username` DESC"; Quote Link to comment Share on other sites More sharing options...
fenway Posted January 16, 2007 Share Posted January 16, 2007 Well, yes, if you want each to be descending, then you need to specify it... it defaults to ascending. Quote Link to comment Share on other sites More sharing options...
jaymc Posted January 16, 2007 Author Share Posted January 16, 2007 I dont mean it doesnt output the correct results, I mean, i get no output at all Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 16, 2007 Share Posted January 16, 2007 This will check for any errors$query='SELECT * FROM '.$prefix."_online WHERE ($timestamp-rtime)<20 ORDER BY `group`, `gender`, `username` DESC";$sql=mysql_query($query)or die(mysql_error); Quote Link to comment Share on other sites More sharing options...
jaymc Posted January 16, 2007 Author Share Posted January 16, 2007 ThanksSolved Quote Link to comment 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.