有条件更新sql查询错误
update contentpagenav
set active = case
when active = 0 then active = 1
when active = 1 then active = 0
end
我收到以下错误
消息 102,级别 15,状态 1,第 3 行 “=”附近的语法不正确。
update contentpagenav
set active = case
when active = 0 then active = 1
when active = 1 then active = 0
end
I get the following error
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '='.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无需在您的 then 中重新分配 active,“set active =”就是这样做的。
No need to re-assign active in your then, the "set active =" is doing that.
最简单的方法不是使用案例:
如果您要简化问题(出于某种原因需要使用案例):
如果活动的可能值超过 2 个:
The easist way to do this is not with a case:
If you're simplifying your question (you NEED to use CASE for some reason):
If more than 2 possible values for active: