update tbl_addemployee set
amount_due=amount_due+((tsalary/30)*187),
com_salary_date='2016-11-04'
where (forUser='sun4269' and E_id)
我想为每个不同的记录更新com_salary_date,其中forUser ='sun4269' 并且不同的列名称是E_id
答案 0 :(得分:0)
您需要使用INNER JOIN
加入匹配的不同记录UPDATE
T
SET
T.amount_due = amount_due+((tsalary/30)*187),
T.com_salary_date = '2016-11-04'
FROM
tbl_addemployee AS T
INNER JOIN
(
SELECT DISTINCT
forUser,
E_id
FROM
tbl_addemployee
) AS X
ON X.forUser=T.forUser AND X.E_id=T.E_id