[英]Empty else for case when
I'm updating multiple columns using case when. 我正在使用case when更新多个列。 I want no action taken on cases not handled by when.
我不想对没有处理的案件采取任何行动。 I read this could be accomplished by using a begin end, but this doens't work for me.
我读过这可以通过使用开头来完成,但这对我不起作用。
My syntax is: 我的语法是:
update site_configuration set value =
case
when attribute_name="hostname" then "abcdef"
when attribute_name="backend" then "ab"
when attribute_name="col" then "col"
else
begin
end
end case
where uid="abcdef";
Does this syntax look right? 这种语法看起来不错吗?
Thanks 谢谢
Use just 使用公正
else `value`
In this case the value of the value
column will be left the same 在这种情况下,值列的
value
将保持不变
Instead you can add one more condition to your where
相反,您可以在您的
where
添加一个条件
where uid="abcdef" AND attribute_name IN ('hostname', 'backend', 'col')
in this case you just omit else
clause 在这种情况下,你只需省略
else
子句
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.