SQL change value

I am trying to execute a select query where I am trying to change a value.

select * from config where category = 'basic' 

For example, I would like the output to show 'general' instead of 'basic' . But I do not want to update all the values โ€‹โ€‹of 'basic' in 'general'

Is there any way to do this?

+7
source share
3 answers

Try the following:

 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' 
+7
source

Use case .. When the operator resolves your problem

 select case when category = 'basic' then 'general' else category end from config 
+2
source
 select c.foo, c.bar, 'general' from config c where c.category = 'basic' 
+1
source

All Articles