MYSQL Update Single column with different values

mysql, sql, sql-update

Solution

`CALL` is a reserved keyword and needs to be escaped.

UPDATE  Trade
SET     `CALL` = CASE   WHEN `Call` = 'C' THEN 'CE'
                        WHEN `Call` = 'P' THEN 'PE'
                    ELSE `CALL` END
WHERE   `CALL` IN ('C','P')

Problem

There is this table "`Trade`" with column "`call`",Call contains `values(C,P)` when loaded from CSV I want to update Trade from java program such that `if call='C' then call='CE'` and `if call='P' then call='PE'` I figured out this can be done using 2 queries.like this ``` update Trade set call='CE' where call='C'; update Trade set call='PE' where call='P'; ``` is there anyway this can be done in single query?

Original source

Related problems