I would like to update multiple columns in a table based on values from a second table using a Select
statement to obtain the values like this:
UPDATE tbl1
SET (col1, col2, col3) = (SELECT colA, colB, colC
FROM tbl2
WHERE tbl2.id = 'someid')
WHERE tbl1.id = 'differentid'
However, it doesn't seem as though it's possible to 'SET' more than one column name - are there alternatives rather than writing separate update statements for each column?
UPDATE tbl1
SET col1 = (SELECT colA FROM tbl2 WHERE tbl2.id = 'someid')
WHERE tbl1.id = 'differentid'
UPDATE tbl1
SET col2 = (SELECT colB FROM tbl2 WHERE tbl2.id = 'someid')
WHERE tbl1.id = 'differentid'
UPDATE tbl1
SET col3 = (SELECT colC FROM tbl2 WHERE tbl2.id = 'someid')
WHERE tbl1.id = 'differentid'