i am curious about how updating a table with inner join works. if i run the following statement:
update tbl1 a
inner join tbl2 b using (id)
set a.val = b.val;
what happens to the records in tbl1 that do not have a match in tbl2? will they simply not be updated and left as is in tbl1? will they be deleted?
i realize i can run this and get the answer but i’m also interested in the mechanics of how this works behind the scenes and was hoping somebody could elucidate this for me.
The update statement is operating on tbl1.
The join is providing a filter that specifies which rows to update in tbl1.
As an added bonus, the join is also providing a value for the column.
The update statement does not and cannot delete rows from a table.