I'm trying to do a select query where I'm trying to change the value.
select * from config where category = 'basic'
For example I would like that the output shows 'general' instead of 'basic'. But I don't want to update all the 'basic' value's into 'general'
Is there a way to do this?
Try this:
SELECT field1, field2, ...,
CASE
WHEN category = 'basic' THEN 'general'
ELSE category
END
FROM config
or, in this particular case:
SELECT field1, field2, ...., 'general'
FROM config
WHERE category = 'basic'
Make use of Case.. When statement resolve your issue
select
case when category = 'basic' then 'general' else category end
from config
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