For now I have following query:
SELECT "type" AS "modifiedType"
FROM "Table"
WHERE "type" = 'type1' OR "type" = 'type2'
What I want is to return modifiedType
like this:
if "type" = 'type1' then 'modifiedType1'
else if "type" = 'type2' then 'modifiedType2'
So I just want to modify column value with another value based on original column value. Type column in ENUM
not string.
I am using Postgres 9.3 (or 9.4?).
Use a CASE
statement:
select type,
case
when type = 'type1' then 'modifiedType1'
when type = 'type2' then 'modifiedType2'
else type
end as modifiedType
from the_table
WHERE type in ('type1', 'type2')
Btw: type
is not a good name for a column
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments