forum

Home / DeveloperSection / Forums / How to surface a value for more than one row in MySQL

How to surface a value for more than one row in MySQL

Anonymous User240818-May-2013
Hi Expert!

I know that I can surface a row in a query by using it in the ORDER BY like this :

SELECT IF(`category` IS NOT NULL,`category`,"Uncategorized") AS `category` FROM `table` ORDER BY `category`="Uncategorized" DESC which will make the first row always contain "Uncategorized", however I have multiple rows that contain it that I also want surfaced. Here are two sample sets of returned data:

What I'm getting:

Uncategorized
Science
Health
Uncategorized
Wellness
What I want:

Uncategorized
Uncategorized
Health
Science
Wellness

I have tried a number of other things including a CASE and also using a conditional IF. What am I doing wrong?

Thanks in advance! 

Updated on 18-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By