Ordering by content of record

Hi,
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 :slight_smile:

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.

Adrien

Yes there is, I remember seeing it more than once here in this forum. I just can’t remember how :smiley:
So try a search, or wait for someone else that knows how.

Off Topic:

What topics do you feel the forums aren’t covering?

Thanks Guido!
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 :slight_smile:

Off Topic:

Well, we do have the server management and [URL=“http://www.sitepoint.com/forums/forumdisplay.php?f=199”]apache configuration forums. I don’t know if they cover the L and A, I never go there myself :slight_smile:

Wow, I do look like a noob now!

ORDER BY CASE WHEN color = ‘black’ THEN ‘alphonse’ ELSE ‘gaston’ END, color

:smiley:

Now I remember… :smiley:

Brilliant, thanks guido: it works perfectly.

you’re welcome, and my name’s not guido

:smiley: :smiley:

oops, sorry :slight_smile:

no problem, i was just kidding around

:slight_smile:

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? :slight_smile:

<— They’ve got a Cave Troll