I have two tables 'A', 'B'. I want to write a query that accomplishes the results shown below.
currently I have this statement
UPDATE A
SET version = (
SELECT B.version
FROM B
WHERE B.id = A.id
)
It works, but it updates ALL the rows, how can I write it so that only the null values are updated ?
CodePudding user response:
UPDATE A SET version = ( SELECT B.version FROM B WHERE B.id = A.id ) where A.version is null