在sql server中更新表 [英] update table in sql server

查看:344
本文介绍了在sql server中更新表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



i必须更新我的桌子:



id name city

1 test1 ahmedab​​ad

2 test2 pune

3 test3 ahmedab​​ad

4 test4 pune



更新城市艾哈迈达巴德到浦那并向艾哈迈达巴德拼凑。如下所示:



id name city

1 test1 pune

2 test2 ahmedab​​ad

3 test3 pune

4 test4 ahmedab​​ad



提前感谢。

解决方案

  update  tblnm  set  city =  case   city = '  ahmedab​​ad' 然后 '  pune'  else  '  ahmedab​​ad' < span class =code-keyword> end  
其中 city ' ahmedab​​ad'' pune'



快乐编码!

:)


  1  update  Mytable  set  city = '  Ahmedab​​ad' 其中 id  in  2  4 
2 update Mytable set city = ' Pune' where id in 3 1 '


hello,

i have to update my table:

id name city
1 test1 ahmedabad
2 test2 pune
3 test3 ahmedabad
4 test4 pune

update city ahmedabad to pune and pune to ahmedabad. like below:

id name city
1 test1 pune
2 test2 ahmedabad
3 test3 pune
4 test4 ahmedabad

thanks in advance.

解决方案

update tblnm set city = case when city = 'ahmedabad' then 'pune' else 'ahmedabad' end
where city in ('ahmedabad','pune')


Happy Coding!
:)


1) update Mytable set city='Ahmedabad' where id in (2,4)
2) update Mytable set city='Pune' where id in (3,1)'


这篇关于在sql server中更新表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆