gpt4 book ai didi

mysql - 从数据库中选择没有值组合的项目

转载 作者:行者123 更新时间:2023-12-01 00:43:41 25 4
gpt4 key购买 nike

在我的表格中有两列:已完成和已关闭。我想要一个 select 来显示所有没有两个值都为 1 的项目。这就是我正在尝试的,但它不会显示其中一个为 1 而另一个为 0 的项目:

 select * from `operations` where (`finished` != 1 and `closed` != 1) 

最佳答案

 select * from `operations` where (`finished` != 1 or `closed` != 1) 

应该做的伎俩,或者替代

 select * from `operations` where !(`finished` = 1 and `closed` = 1) 

你可以用你的英文句子来解码。我的意思是,“两个值都为 1”相当于 finished=1 和 closed=1,那么“没有两个...”就像 not 其中,即 !(finished=1 and closed=1)

关于mysql - 从数据库中选择没有值组合的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25843263/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com