Merge,依据查询结果更新字段
依据另一个表的查询结果,更新当前表,可以使用merge关键字
依据考核表中统计的考核结果,更新工资表中的考核值。
Merge Into tr_salary p Using (Select staff_id,sum(reward_sum) As reward_goods From tp_check_goods Group By staff_id) np -- On (p.staff_id=np.staff_id ) when matched then update set p.reward_goods = np.reward_goods Where dept_Id='02' And p_year=2015 And p_month=6 --