Sql updating multiple columns from another table
For small numbers of rows requiring updates, it can be adequate to use an UPDATE statement for each row that requires an update.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.Optimising the number of UPDATEs by grouping the distinct SET values can be done in a way which is compatible with most common SQL databases. FROM approach requires knowledge of the specific SQL database being used.So is structured so that approaches which are generic across different SQL databases are expressed in a base class, and approaches which only work for specific SQL databases are expressed in a subclass.
“value_columns” specifies the columns which will be updated (using SET). The second element provides the value to be SET in the column specified by “value_columns”.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”.