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? 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"); 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
Archived
This topic is now archived and is closed to further replies.