1

Is there any possible way we can use join in merge statement?

MERGE INTO TABLE1 T
   USING TABLE2
   ON .....
   WHEN MATCHED THEN .....
   WHEN NOT MATCHED THEN INSERT (X,Y,Z1) VALUES (X,Y,Z1);

X and Y belong TABLE2 and no problem with merging, but I also want to insert Z1 from another TABLE3, when merging into TABLE1.

I am trying to join TABLE3 but it's not allowed in Merging syntax.

Is there any way to do so?

1
  • 1
    Try using a subquery in place of the table. Commented May 9, 2015 at 11:48

1 Answer 1

1

The USING clause can take a subquery as its argument. It sounds like you want something like this:

MERGE INTO table1 t
USING (
  ... subquery joining TABLE2 and TABLE3 ...
) f
ON f.something = t.something
...
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.