0

I have two tables 'A', 'B'. I want to write a query that accomplishes the results shown below.

enter image description here

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 ?

1 Answer 1

1

UPDATE A SET version = ( SELECT B.version FROM B WHERE B.id = A.id ) where A.version is null

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.