treez Posted March 23, 2006 Share Posted March 23, 2006 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 Link to comment https://forums.phpfreaks.com/topic/5636-secondary-ordering-on-a-php-mysql-statement/ Share on other sites More sharing options...
underparnv Posted March 23, 2006 Share Posted March 23, 2006 [!--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"); Quote Link to comment https://forums.phpfreaks.com/topic/5636-secondary-ordering-on-a-php-mysql-statement/#findComment-20138 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.