2 Replies Latest reply on Jul 25, 2015 7:12 AM by Etbin

    Joins used in MERGE command

    KVB

      Hi

       

      I have a Table 1 and Table 2 joined on some conditions and INSERT/UPDATE the data in Table 3.

       

      I have found examples on MERGE command using only 2 tablesbelow.. Can i use Joins in the USING clause like (select * from table inner join table 2 on .....) .. Suggest me .

       

      SQL> merge into student a

        2 using

        3 (select id, name, score

        4 from student_n) b

        5 on (a.id = b.id)

        6 when matched then

        7 update set a.name = b.name

        8 , a.score = b.score

        9 when not matched then

      10 insert (a.id, a.name, a.score)

      11 values (b.id, b.name, b.score);

       

      Can i use something like this

       

      MERGE into Table3

      USING

      (

      SELECT A.* FROM TABLE A INNER JOIN TABLE B ON A.ID=B.ID) Table2

      on(Table2.Id=table3.ID)

       

      when matched then ........