Last post Apr 29, 2021 02:08 AM by yij sun
Apr 28, 2021 09:43 AM|20141113|LINK
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?
Apr 29, 2021 02:08 AM|yij sun|LINK
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: