3

谁能告诉我如何更新具有相同值的行数..?

例如,如果我有一个员工表,例如,

employee id   salary
    1           100
    2           230
    3           120
    4           360
    5           190

如果我希望员工 1、2 和 5 具有相同的薪水,例如 300... 如何使用单个查询更新它?

谢谢

4

2 回答 2

14
update employee
set salary = 300
where [employee id] in (1,2,5)

或者

update employee
set salary = 300
where [employee id] = 1
   or [employee id] = 2
   or [employee id] = 5
于 2013-10-04T11:38:54.257 回答
3

请试试:

Update
    YourTable
SET 
    Salary=300
WHERE
    [employee Id] IN (1, 2, 5)
于 2013-10-04T11:39:23.917 回答