merge table RRS feed

  • Question

  • User-583959464 posted

    merge into tables T using (select * from tableB) as S on t.id =s.id and t.name=s.name when matched then update t.value = s.value

    when not matched then insert (colA, colB ) values (s.id, s.name);

    how to use merge table above , and colA, and colB in not matched section is referring to insert which ?

    anyone explain above sql on merge match and not match?

    Wednesday, April 28, 2021 9:43 AM

All replies

  • User1535942433 posted

    Hi 20141113,

    SQL have a great syntax.That's LEFT JOINS.  The SQL LEFT JOIN returns all rows from the left table, even if there are no matches in the right table. This means that if the ON clause matches 0 (zero) records in the right table; the join will still return a row in the result, but with NULL in each column from the right table.

    You could Table B left join Table T.

    More details,you could refer to below article:


    Best regards,

    Yijing Sun

    Thursday, April 29, 2021 2:08 AM