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..?
CASE TRIM(IFNULL(channel_id,''))
WHEN '' THEN 'General'
ELSE 'Specific'
END AS templateType
Try this..
CASE WHEN channel_id > '' THEN
'Specific'
ELSE
'General'
END As templateType
Aside:
SELECT CASE WHEN '' = ' ' THEN 'same' ELSE 'different' END
Results:
same
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.