Prior to execution:
Merge into UserInfo u using chartinfo C on U.userid=c.userid if matched and u.username=c.username then update set U.lastupdate=c.lastupdate when is not matched--cannot be update for not matched (no match succeeded of course cannot update) then Insert (Username,sex) VALUES (' Zhangzhao ', ' B ');
After execution
The merge and using collocation is used for data statistics and analysis in particular on BI, such as requiring data that is not in the child table, then the parent table will delete the corresponding data to ensure that the data corresponding to the child table and the parent table is followed by the usual practice of running a job and then passing the cursor/table-valued Function/ Temporary tables and so on loop fetch data and then update the parent table It's a waste of efficiency. Then the merge comes in handy.
Usage of merge-using in SQL Server