Reputation: 825
I am writing a query to display an alias column with respect to a column value. below is my code
CASE TRIM(channel_id)
WHEN '' THEN 'General'
ELSE 'Specific'
END AS templateType
When the column channel id is empty/null the templateType column should show 'General' else should show 'Specific'
I am getting wrong output Can anyone help me please..?
Upvotes: 2
Views: 1705
Reputation: 111
CASE TRIM(IFNULL(channel_id,''))
WHEN '' THEN 'General'
ELSE 'Specific'
END AS templateType
Try this..
Upvotes: 3
Reputation: 17161
CASE WHEN channel_id > '' THEN
'Specific'
ELSE
'General'
END As templateType
Aside:
SELECT CASE WHEN '' = ' ' THEN 'same' ELSE 'different' END
Results:
same
Upvotes: 0