Users Pricing

forum

Home Forums How to surface a value for more than one row in MySQL – MindStick

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

Anonymous User 2839 18 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
Uncategorized
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

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md