The Little Guy Posted January 9, 2010 Share Posted January 9, 2010 I though I have done something similar to this query in the past: SELECT * FROM docs WHERE (`type` = 'method' OR `type` = 'property') AND `class` = 'Nebala' ORDER BY `type` ORDER BY `title` I am getting an error with my second ORDER BY, but for some reason I though I have done that in the past. My table has a few columns, but I want to do is get anything from the table where the type is either property or method, I want all properties to display first then the methods in the returned result. I then want to order the titles in alphabetical order in those two groups. so... - properties: abc cat url - methods another fisrt second version as you can see properties come first and are listed in abc order in that group, and then methods come next which are in abc order in that group as well. So what am I doing wrong, I am stumped! Quote Link to comment https://forums.phpfreaks.com/topic/187814-ordering-results/ Share on other sites More sharing options...
cags Posted January 9, 2010 Share Posted January 9, 2010 You only need ORDER BY once, but you can specify multiple columns... SELECT * FROM docs WHERE (`type` = 'method' OR `type` = 'property') AND `class` = 'Nebala' ORDER BY `type`, `title` Just add in ASC or DESC as required after the column names in the ORDER BY section Quote Link to comment https://forums.phpfreaks.com/topic/187814-ordering-results/#findComment-991637 Share on other sites More sharing options...
The Little Guy Posted January 9, 2010 Author Share Posted January 9, 2010 Ahh! That is what I was doing wrong. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/187814-ordering-results/#findComment-991819 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.