有人能告诉我如何使用相同的值更新多个行吗?
例如,如果我有一个员工表,如
employee id salary
1 100
2 230
3 120
4 360
5 190
如果我希望员工1,2和5拥有相同的薪水,比如300 ... 如何使用单个查询更新它?
谢谢
答案 0 :(得分:10)
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
答案 1 :(得分:3)
请尝试:
Update
YourTable
SET
Salary=300
WHERE
[employee Id] IN (1, 2, 5)