0
A
回答
2
可以与update
改变值,比如:
update YourTable set Course = 'ASP.NET' where id = 2
update YourTable set Course = 'C++' where id = 4
或:
update YourTable
set Course =
case id
when 2 then 'ASP.NET'
when 4 then 'C++'
end
where id in (2,4)
0
测试表和数据
create table YourTable(id int primary key, course varchar(10))
insert into YourTable values (1, 'Delphi')
insert into YourTable values (2, 'C++')
insert into YourTable values (3, 'Clipper')
insert into YourTable values (4, 'ASP.net')
更新到开关2和4
update YourTable set
course = case id
when 4 then (select course from YourTable where id = 2)
when 2 then (select course from YourTable where id = 4)
else T.course
end
from
YourTable as T
where T.id in (2, 4)
结果
id course
1 Delphi
2 ASP.net
3 Clipper
4 C++
相关问题
- 1. 交换SQL Server表中的两个值
- 2. SQL Server中同一个表中两行的交换值
- 3. 交换表的行只对第二次
- 4. SQL:交换列值
- 5. 交换行值
- 6. 在2表中插入值,其中第2表需要第1表中的ID
- 7. SQL - 交换/交换字段值
- 8. SQL Server表交换
- 9. 如何交换表中第一列的第一个值在mysql中
- 10. 如何交换表中2个记录的列值?
- 11. 交换表行
- 12. 替换sql表中的值
- 13. SQL交换字段值
- 14. html表值交换
- 15. 在单个SQL查询中交换同一表的列值
- 16. 如何在SQL Server中交换值?
- 17. SQL - 更新表2中的table1的值
- 18. 替换第一行中的值
- 19. 回声2 PHP中的SQL行值PHP
- 20. 如何在字典中交换2个值,给定第3个关键字?
- 21. SQL替换列的第一个值与第二个值
- 22. 交换表行的onmouseover
- 23. 从两个sql server表中交换列
- 24. 如何交换dataTable行值?
- 25. 在SQL Server中加入3个表并删除第2个和第3个表中的空值
- 26. SQL从表中获取第一个值
- 27. 如何在有2个提交值时在JavaScript中提交表单中的值?
- 28. 交换机注册表值
- 29. SQL:查找SQL表中第一行第一列
- 30. imagettftext \\ n换行符第2部分