Jump to content

secondary ordering on a php mysql statement


treez

Recommended Posts

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?
Link to comment
Share on other sites

[!--quoteo(post=357788:date=Mar 23 2006, 02:55 PM:name=treez)--][div class=\'quotetop\']QUOTE(treez @ Mar 23 2006, 02:55 PM) [snapback]357788[/snapback][/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");
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.