Bizty Posted April 20, 2009 Share Posted April 20, 2009 This may have a rather simple solution but seeing I've been coding for the good part of 2 days of 10 hour sessions I've roasted my brain. Basicly I have a table with 2 data-lables. for simplicity I'll make a simple illustration. someTable id, name, age some simple data (id, name, age): 1, Dennis, 24 2, Peter, 13 3, Hans, 49 4, Andy, 23 5, Marcus, 29 6, JohnDoe, 58 Now I want my output to be sorted by the 'id': mysql_query("SELECT * FROM someTable ORDER BY id"); further I want my ORDERED output sorted by age, how do I do that? Hope you get it, pretty smashed atm, so might be a poor example. Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/ Share on other sites More sharing options...
soak Posted April 20, 2009 Share Posted April 20, 2009 WHat's the difference between output and ordered output? Why not just order the orig query by age? Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/#findComment-814742 Share on other sites More sharing options...
wildteen88 Posted April 20, 2009 Share Posted April 20, 2009 You can list more than one column in your ORDER BY clause. eg ... ORDER BY id, age Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/#findComment-814743 Share on other sites More sharing options...
Maq Posted April 20, 2009 Share Posted April 20, 2009 ORDER BY age, id Do you want to order by the age, but if there are multiple records for that age, order that subset by id? If you order by id first it's just going to order by id and nothing else. Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/#findComment-814744 Share on other sites More sharing options...
Bizty Posted April 21, 2009 Author Share Posted April 21, 2009 Ok, gonna try and take the example from what I am working on the ORDER BY id, age - didn't quite work. I have a table: id, player_rank, player_roll lets say I have 30 entries here, 30 different players. Firstly, I want them listed by the player_rank DESC so ie: 10 players with the rank 1-10 ORDER BY player_rank DESC 10 9 8 7 6 5 4 3 2 1 The player_rank is changeing upon certain events, the important thing is that they can be equal, which is why I have player_roll aswell, lets say we have these 10 players with these player_rank values and player_roll values player_rank(player_roll) ----------------------- 10(58) 9(43) 9(97) 7(100) 6(23) 6(84) 3(41) 2(95) 2(13) 1(1) Now thats ordered by the player_rank allright, but I want it to order the player_roll where it's equal, again DESC, so it should look like this: player_rank(player_roll) ----------------------- 10(58) 9(97) 9(43) 7(100) 6(84)--\ -----84 is higher than 23, hence the ORDER BY player_roll DESC puts it first. 6(23)--/ 3(41) 2(95) 2(13) 1(1) Much like Maq suggested (I think), cheers for all the help so far it's superb that a hat like me can get a hand sometimes Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/#findComment-815101 Share on other sites More sharing options...
premiso Posted April 21, 2009 Share Posted April 21, 2009 I do not know if this is solved...??? If not try ORDER BY player_rank DESC, player_roll DESC that should order by rank first and roll second both in descending order. Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/#findComment-815107 Share on other sites More sharing options...
Bizty Posted April 21, 2009 Author Share Posted April 21, 2009 Last one did it, thankyou alot guys Quote Link to comment https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/#findComment-815318 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.