Jump to content

[SOLVED] Multiple query output filters


Bizty

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/154901-solved-multiple-query-output-filters/
Share on other sites

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 :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.