本文介绍了在不使用SELECT的情况下将布尔值更新为SQL中的相反值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过告诉bool字段将字段更新为与其相反的字段而无需选择该值,从而进行升级-检查它然后进行相应的更新,这似乎很麻烦...
Is it possible to upgrade a bool field by telling it to update the field to the opposite of what it is without having to select the value - check it then update accordingly which seems long winded...
我的意思的伪例子
UPDATE `table` SET `my_bool` = opposite_of(my_bool)
当前,我必须在一个查询中选择my_bool,然后对其值进行快速检查,以便可以在第二个查询中更新表.
Currently i have to SELECT my_bool in one query then do a quick check on its value so i can update the table in a second query.
我希望将其简化为单个查询(如果可能)?
I was hopeing to cut that down to a single query if that is possible ?
推荐答案
使用NOT
UPDATE `table` SET `my_bool` = NOT my_bool
这篇关于在不使用SELECT的情况下将布尔值更新为SQL中的相反值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!