In the case of Postgre SQL, it can be done using a FROM clause with UPDATE, like this: This does an INNER JOIN between the tables “staff” and “updates” where the column “name” matches.
The SET clause then takes the “salary” field from the “updates” table and uses it to update the “salary” field of the “staff” table.
Also, let’s say we want to make updates only for people in the company “Widget Co”.
and we could persuade the database server to apply those updates to the target table?
This is in fact entirely possible in many database systems.
If there is no database-specific subclass for the database in use, then will just use the base class which implements approaches that should work for any SQL database.
At the time of writing, the only database-specific subclass is for Postgre SQL. Let’s expand the original table a bit: “name” has now been split into “first_name” and “last_name”.
But if there are a large number of rows that require an update, then the overhead of issuing large numbers of UPDATE statements can result in the operation as a whole taking a long time to complete.