当前位置: 代码迷 >> Sql Server >> 初学者有关问题求解答
  详细解决方案

初学者有关问题求解答

热度:3   发布时间:2016-04-27 13:17:19.0
菜鸟问题求解答
数据库有一个字段 count 如果这个count值是1那么就更新为0,如果是0就更新为1 如何用一句sql搞定?

------解决方案--------------------
update tb set [count]=(case [count] when 0 then 1 when 1 then 0 end)
------解决方案--------------------
SQL code
update MyTable set [count]=case when [count]=0 then 1 when [count]=1 then 0 end
  相关解决方案