0

Suppose I have a simple update of one table with data from another table.

update t1
   set (a,b) = (select a,b from t2 where id=17)
 where id=17;

How can i apply a similar update to multiple id's in one statement? In my brain I'm thinking iteratively of something like this:

for X in (select id from t2 where ...):
    update t1
       set (a,b) = (select a,b from t2 where id=X)
     where id=X;

Generic SQL preferred, but Oracle-specific solutions welcomed as well.

1 Answer 1

1

How about:

update t1
   set (a, b) = (select a,b from t2 where t2.id=t1.id)
 where t1.id in (select id from t2 where ...);
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.