Update with Inner Join

3

update will affect all fields that satisfy the imposed condition in the inner join or just the first field?

    
asked by anonymous 18.10.2015 / 12:36

1 answer

10
The UPDATE will only be done in the column of the table you are designating, in other words, only the columns with SET will be updated

See the example:

UPDATE tb1
SET tb1.column_1 = tb2.column_1
FROM table_1 AS tb1
INNER JOIN table_2 AS tb2
ON tb1.column_2 = tb2.column_3

Now, by answering your question, the ON clause is used to filter the records in which you want to update, that is, by looking at the example, only the columns matching the ON tb1.column_2 = tb2.column_3 equivalency will be updated.

I hope I have helped.

    
18.10.2015 / 13:58