Sql updating multiple rows

Posted by / 05-Aug-2020 14:49

If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site. I have about 60,000 rows that I'm needing to update the information from column_a to column_b.

This is in fact entirely possible in many database systems.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.So we could think in terms of creating a re-usable module which would implement that logic.This is the intention of UPDATE staff SET salary = 1200 WHERE name = ' Bob'; UPDATE staff SET salary = 1200 WHERE name = ' Jane'; UPDATE staff SET salary = 1200 WHERE name = ' Frank'; UPDATE staff SET salary = 1200 WHERE name = ' Susan'; UPDATE staff SET salary = 1200 WHERE name = ' John'; “key_columns” specifies the columns which will be used to identify rows which need to be updated (using WHERE). The first element provides the value of the column (specified by “key_columns”) to identify the row to be updated.

sql updating multiple rows-86sql updating multiple rows-3sql updating multiple rows-44

OK, that’s great, we have some theoretical approaches for reducing the number of queries, now what?