(1) How to update the data of another table in one UPDATE statement with the data of one table
Update AA
Set aa.ac=
(select top 1 dd from CC where CC.AA=AA.AA)
This statement updates each row in the AA table, and the specific execution process is
Iterate through each row of the AA table and then conditionally: Select top 1 dd from CC where CC.AA=AA.AA
Assign the column dd of the corresponding row in the CC table to the column AC of the AA table
(Note: Every column in the cc.aa= (<>) AA.AA,AA table will be updated)
(2) Update AA
Set aa.ac=
(select top 1 dd from CC where CC.AA=AA.AA)
where
Exists (SELECT * from CC where CC.AA=AA.AA)
This statement updates the satisfies condition in the AA table: Exists (SELECT * from CC where CC.AA=AA.AA)
All rows
Update AA
Set aa.ac=
(select top 1 dd from CC where CC.AA=AA.AA)
where
Aa.aa in (select AA from CC where AA.AA=CC.AA)
The statement is equivalent to the above statement (2)
(3) Update (select Aa.ac ac,cc.dd dd from AA,CC where AA.AA=CC.AA)
Set AC=DD
This statement also implements the same functionality, but it seems that SQL Server 2005 does not support this format, but it can be done in Oracle (this statement is simpler)