I have two tables, one Master and one ExtraData. Both tables share columns FirstName, LastName, Gender and A_Id.
The query I am working on should compare the two tables and UPDATE any NULL values for A_Id in Master using A_Id in Extra.
What is the best way to do this? I could compare CONCAT(FirstName, LastName, Gender) but I’m stuck on how to update the column based on a JOIN.
You can use many criteria in a join, and then simply set a column in one source table to the value of a column in the other table:
Note that the JOIN condition can be made more succinct (because the columns are named the same):
JOIN ExtraData USING (FirstName, LastName, Gender)