Sort sql query results twice using different values?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Sort sql query results twice using different values?
Larcen
CZ Super Newbie
Larcen has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 36
Points: 1,270
   
This may or may not be possible, I haven't seen anything relevant looking through php.net for a solution, maybe I have seen the answer and just not noticed it.

I want to query and sort by 'something numerical' asc and then sort again alphabetically within the numerical sorting. For instance. Two rows where one's $lev is 2 and the other is 1. So they are sorted 1 first then 2. Then sort again alphabetically so when I list them in the loop it'll print the 1 first and it's $var aplphabetically as well. I hope this makes sense



Back to top Reply with quote
#2   re: Sort sql query results twice using different values?
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
Its that word "within" thats kicking my butt. Not that it is not possible, but I have no quick solution for you. The only way I could think of is to print it twice and you obviously don't want that.

I would think they have to relate to each other in some way. I understand what you want, I just can't figure out why. icon_biggrin.gif

<--picks up his imaginary phone to call telli.



Back to top Reply with quote
#3   re: Sort sql query results twice using different values?
Larcen
CZ Super Newbie
Larcen has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Apr 02, 2004
0.00 posts per day
Posts: 36
Points: 1,270
   
Let me give you a direct example. there is a table named nuke_feats. in its structure there is a flevel (which is numbers only)row and a fname (which is aplhabetical names) row. on the output page I'm seperating each into 2 colums per result. But, I want to seperate the Numbers (IE: Seperate all the #1's then the #2's so on and so forth) And in the #1's sort them Aphabetically.

I just had an idea, which is what I should have tried before asking, in my query change the where flevel is 1 and then sort by name asc. Then for the next section where flevel is 2 so on and so forth. Sheesh. I should have thought of that sooner.



Back to top Reply with quote
#4   re: Sort sql query results twice using different values?
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
Ah, I see what your saying. I have never tried a treat like this. So let me know where your fresh idea leads you. I personally do best when I can look at the code. You might wanna attach a snipplet of the code in zip.



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum