Jump to content

Archived

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

treez

secondary ordering on a php mysql statement

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?

Share this post


Link to post
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");

Share this post


Link to post
Share on other sites

×

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.