Use a Case statement with an SQL Update command

Here is an example of UPDATE SQL statement with Case statement.


UPDATE table1
    Set name = CASE
    When name like 'A %' THEN (SUBSTRING(name, 5, 255) + ', D')
    When name like 'B %' THEN (SUBSTRING(name, 4, 255) + ', E')
    When name like 'C %' THEN (SUBSTRING(name, 3, 255) + ', F')
    Else name
    END;
Ebook Download
View all
Learn
View all