Description:
Running an SQL script that performs a update depending on some given conditions.
Solution:
SQL query can take if clauses in the shape of cases:
UPDATE table
SET name = case
WHEN id = 1 then ‘John’
ELSE null
END,
SET name = case
WHEN id = 2 then ‘Mark’
ELSE null
END
WHERE reference != 0;