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:
- there is a black model for every model
- there are all kinds of colors so that a simple “ORDER BY color ASC” will not work
- 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.
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?
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
Wow, I do look like a noob now!
ORDER BY CASE WHEN color = ‘black’ THEN ‘alphonse’ ELSE ‘gaston’ END, color
Brilliant, thanks guido: it works perfectly.
you’re welcome, and my name’s not guido
no problem, i was just kidding around
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