When you update a table in bulk, you need to rely on a different table when you update a column of a table, which can be a where conditional clause, or the value of the field that you want to update depends on another table
There are usually two ways of doing
1. Using Stored Procedures
2. Loop through the program code
Here is a more efficient, concise approach, batch update SQL, a SQL can replace the troublesome loop process, with MS SQL Server, Oracle, DB2 under the wording
--Key points: T4 and T1 are the same table,primary key.
-and associate it so that you can refer to the fields of the table you want to update in the SELECT statement
UPDATE Table1 as T1
SET (field1,field2) = (SELECT Field21, Field22
From Table2 T2
INNER JOIN Table3 T3
on T3. Field31 = t2. Field23
INNER JOIN Table4 T4
on T3. FIELD32 = T4. Filed41
WHERE T2. Field24 >= '
and T1.fid = T4.fid);
----------------------------MS SQL Server--------------------------------------
UPDATE T1
SET Field1 = Field21, Field2 = Field22
From Table2 T2
INNER JOIN Table3 T3
on T3. Field31 = t2. Field23
INNER JOIN Table4 T4
on T3. FIELD32 = T4. Filed41
WHERE (T2. FIELD24 >= ")
and T1.fid = T4.fid);
----------------------------Oracle--------------------------------------------
UPDATE Table1 T1
SET (field1,field2) = (SELECT Field21, Field22
From Table2 T2
INNER JOIN Table3 T3
on T3. Field31 = t2. Field23
INNER JOIN Table4 T4
on T3. FIELD32 = T4. Filed41
WHERE (T2. FIELD24 >= ")
and T1.fid = T4.fid))
WHERE EXISTS (SELECT Field21, Field22
From Table2 T2
INNER JOIN Table3 T3
on T3. Field31 = t2. Field23
INNER JOIN Table4 T4
on T3. FIELD32 = T4. Filed41
WHERE (T2. FIELD24 >= ")
and T1.fid = T4.fid));
---------------------------------DB2------------------------------------------
UPDATE Table1 as T1
SET (field1,field2) = (SELECT Field21, Field22
From Table2 T2
INNER JOIN Table3 T3
on T3. Field31 = t2. Field23
INNER JOIN Table4 T4
on T3. FIELD32 = T4. Filed41
WHERE (T2. FIELD24 >= ")
and T1.fid = T4.fid))
WHERE EXISTS (SELECT Field21, Field22
From Table2 T2
INNER JOIN Table3 T3
on T3. Field31 = t2. Field23
INNER JOIN Table4 T4
on T3. FIELD32 = T4. Filed41
WHERE (T2. FIELD24 >= ")
and T1.fid = T4.fid));
-----Reproduced from the blog park
Update association Other tables Bulk update data