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开发者_C百科 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
select c.foo, c.bar, 'general' from config c where c.category = 'basic'
精彩评论