frodo — 2010-11-10T13:14:16-05:00 — #1
I am kind of getting addicted to SPF as every question I ask always gets a quick answer... I just wish the forums covered more topics
But let's get to my question. Let's imagine I have a database with all kinds of "monitors'" data. One of these pieces of data is the color of the monitor. Is there a way that in any search I do I can make sure the "black" monitors are always ordered first?
Let's assume a couple things:
1. there is a black model for every model
2. there are all kinds of colors so that a simple "ORDER BY color ASC" will not work
3. searches always output more than one model and the black model must appear just before the other colors of the same model
Thanks in advance for your patience.
guido2004 — 2010-11-10T14:18:18-05:00 — #2
Yes there is, I remember seeing it more than once here in this forum. I just can't remember how
So try a search, or wait for someone else that knows how.
What topics do you feel the forums aren't covering?
frodo — 2010-11-10T14:22:59-05:00 — #3
I'll try searching better.
I would like SPF to go the next level down in the stack and start covering the L and the A in LAMP. Not that there aren't other forums doing this, but it seems the community here si fa more active than other watering holes I've found. Please bear in mind this is not meant as a complaint
guido2004 — 2010-11-10T14:35:52-05:00 — #4
Well, we do have the [server management and [URL="http://www.sitepoint.com/forums/forumdisplay.php?f=199"]apache configuration](http://www.sitepoint.com/forums/forumdisplay.php?f=97) forums. I don't know if they cover the L and A, I never go there myself
frodo — 2010-11-10T14:43:38-05:00 — #5
Wow, I do look like a noob now!
r937 — 2010-11-10T14:58:01-05:00 — #6
ORDER BY CASE WHEN color = 'black' THEN 'alphonse' ELSE 'gaston' END, color
guido2004 — 2010-11-10T15:01:29-05:00 — #7
Now I remember...
frodo — 2010-11-10T18:31:01-05:00 — #8
Brilliant, thanks guido: it works perfectly.
r937 — 2010-11-10T18:40:51-05:00 — #9
you're welcome, and my name's not guido
frodo — 2010-11-10T19:37:44-05:00 — #10
r937 — 2010-11-10T19:41:41-05:00 — #11
no problem, i was just kidding around
guelphdad — 2010-11-12T12:43:20-05:00 — #12
Alphonse, Gaston? What ever happened to Larry, Curly and Moe? or seeing the OP's handle is Frodo what about using Gimli and Legolas or simply Frodo and Sam?
<--- They've got a Cave Troll