Jump to content


Photo

secondary ordering on a php mysql statement


  • Please log in to reply
1 reply to this topic

#1 treez

treez
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 23 March 2006 - 10:55 PM

I have this:
$nbresult2 = mysql_query("SELECT * FROM gallery_images WHERE owner = '$user' ORDER BY ordering");

I want it to firstly order everything under the "category" field and then the "ordering" field.

So it'll order the results for the "category" and then for each category order them under "ordering"

i wanna do this as simply as possible and on the same line.


I tried ORDER BY category THEN ordering but I dont think that exists.

Any ideas?

#2 underparnv

underparnv
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationReno, Nevada

Posted 23 March 2006 - 11:10 PM

[!--quoteo(post=357788:date=Mar 23 2006, 02:55 PM:name=treez)--][div class=\'quotetop\']QUOTE(treez @ Mar 23 2006, 02:55 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I have this:
$nbresult2 = mysql_query("SELECT * FROM gallery_images WHERE owner = '$user' ORDER BY ordering");

I want it to firstly order everything under the "category" field and then the "ordering" field.

So it'll order the results for the "category" and then for each category order them under "ordering"

i wanna do this as simply as possible and on the same line.
I tried ORDER BY category THEN ordering but I dont think that exists.

Any ideas?
[/quote]
$nbresult2 = mysql_query("SELECT * FROM gallery_images WHERE owner = '$user' ORDER BY ordering DESC, image_name ASC");
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."

The Sporting Edge - Free NFL Football Pool





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users