In general, we only update a single record, but there are few batch updates. Currently, we provide three methods for batch update:
1. Batch update
Update test a set a. dept_no = (select B. dept_no from test1 B where a. emp_no = B. emp_no)
2. Batch update with multiple columns
Update test a set (A. emp_no, A. dept_no, A. id_no, A. ic_no, A. Status) =
(Select B. emp_no, B. dept_no, B. id_no, B. ic_no, B. status from test1 B where a. emp_no = B. emp_no)
3. Use the merge method to update data
-- Use the merge method to update data
Merge into tb_realtimedatavalue
Using tb_pointconfig B
On (A. FID = B. factoryid and A. uploadid = B. uploadid)
When matched then
Update set a. pointid = B. ID
Where a. FID = 13
This merge update method comes from
Http://www.cnblogs.com/GeneralXU/archive/2009/03/25/1421175.html
The above are my personal summary of the batch update method, of course, we can usually use triggers, stored procedures, etc. to update data, however, sometimes triggers and stored procedures do not necessarily meet our requirements. This method is the fastest and most effective update method.
There are thousands of methods, the fastest and most effective is the best, is the preferred method.
There is no end to learning, and the knowledge is constantly updated. The blog will be constantly updated to share your learning experience with you!