I am needing to update multiple rows in a single column in a postgresql db
I have this:
UPDATE tableA
SET
column_a = CASE WHEN column_a = 'conserve' THEN column_a = 'fixed',
column_a = CASE WHEN column_a = 'balance' THEN column_a = 'moderate',
column_a = CASE WHEN column_a = 'balance growth' THEN column_a = 'moderate growth',
column_a = CASE WHEN column_a = 'aggressive' THEN column_a = 'moderate/agressive';
but am getting a syntax error
Error: syntax error at or near ","
CodePudding user response:
You can do it with one single CASE
statement:
UPDATE tableA
SET
column_a = CASE WHEN column_a = 'conserve' THEN 'fixed'
WHEN column_a = 'balance' THEN 'moderate'
WHEN column_a = 'balance growth' THEN 'moderate growth'
WHEN column_a = 'aggressive' THEN 'moderate/agressive'
END;
Try it here.