I have a query
SELECT id, descr Category, parent_id `Department`, updated `Updated`
, updatedby `By`
FROM category
which returns numbers at the column parent_id. It can only return one of three number (167, 154, 164) at parent_id column. I want to replace those numbers with:
164 - Advertisemnt
167 - Modeling
154 - Finance
How can that be achieved? so , the table should look like:
id category Department Updated By
1 Network Modeling now() Me
Use as CASE statement like this:
SELECT id
,descr AS `Category`
,CASE parent_id
WHEN 164 THEN 'Advertisemnt'
WHEN 167 THEN 'Modeling'
WHEN 154 THEN 'Finance'
ELSE 'Unknown partent_id'
END AS `Department`
,updated AS `Updated`
,updatedby AS `By`
FROM category
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With