Lesson 24. Updating Data With A Join
Sometimes you need to update data, but the columns necessary to identify what needs to be updated cannot be solely found in the target table. In that scenario, you can use a JOIN to get the columns or other information you need.
The syntax for an UPDATE with a JOIN is wildly different than a plain vanilla join.
UPDATE JOIN Syntax
In [ ]:
Examples
Changing A User’s Last Name
Scenario: Barb is getting married and is taking her husband’s last name, so her last name needs to be changed in the system.
The problem is, we only know Barb as Barb and lord knows how many Barbaras there are in the massive multinational we all work at. We can’t just update ALL the Barbs in the Person table and hope ONE of them is right!
We do have Barb’s globally unique ID called a national ID number though. It’s 969985265. But that value isn’t stored in the Person table. That’s in the employee table. UPDATE with JOIN to the rescue!
In [ ]:
Last updated