Consider the update:
UPDATE table1
SET c1 = NVL(( SELECT d1 FROM table2 WHERE table1.id = table2.id ), 0),
c2 = NVL(( SELECT d2 FROM table2 WHERE table1.id = table2.id ), 0)
The NVL function handles the case where the sub-select returns no rows.
Is there a good way to rewrite this (without repeating the sub-select) using this type of syntax:
UPDATE table1 SET (c1,c2) = ( SELECT d1, d2 FROM table2 where table1.id = table2.id )
such that the case where the sub-select returns now rows is handled.
I would change the subselect to include a left outer join on t1, and then nvl the results in that case, eg: