s07q 大佬有话说 :
解决了一个sql查询的小问题,这里说一下
需要在查询结果中剔除满足两个条件的数据,思来想去没搞明白
后来找了下资料,才发现原来 not 和 and 还可以这样来用
对于我这种半路出家的人来说,基础不够扎实,这次算是学到了
过滤条件如下
where
not (aaa = 1 and bbb = 2) and
not (aaa = 2 and bbb = 3)
这样可以剔除 同时满足两个
另外分享个爱国视频
https://alywp.net/6GqIGZ
h20 大佬有话说 :
本帖最后由 h20 于 2021-7-29 18:27 编辑
not (aaa = 1 and bbb = 2)
等价于
(aaa <> 1 or bbb <> 2)
学艺不精,一看就是没吃过离散数学的铁拳,多看看非p非q啥的:lol
不眠飞行 大佬有话说 :
谢谢你 – –
royzheng 大佬有话说 :
where
not (aaa = 1 and bbb = 2) and
not (aaa = 2 and bbb = 3)
=
where
(aaa <> 1 or bbb <> 2) and (aaa<>2 or bbb<>3)
royzheng 大佬有话说 :
h20 大佬有话说 : 2021-7-29 18:19
not (aaa = 1 and bbb = 2)
等价于
(aaa1 and bbb2)
你也错了吧
h20 大佬有话说 :
royzheng 大佬有话说 : 2021-7-29 18:26
你也错了吧
打错了,非(p且q)=非p或非q
翻车小王子 大佬有话说 :
h20 大佬有话说 : 2021-7-29 18:27
打错了,非(p且q)=非p或非q
水王学霸的一面,厉害。。。
s07q 大佬有话说 :
h20 大佬有话说 : 2021-7-29 18:19
not (aaa = 1 and bbb = 2)
等价于
(aaa1 or bbb2)
学习了,还是书读的少啊
朕的大清完了? 大佬有话说 :
奇葩要求,直接在程序里面过滤不行吗,非要把sql累死
llyang 大佬有话说 :
最笨的办法是
where
(not (aaa = 1 and bbb = 2)) and
(not (aaa = 2 and bbb = 3))
只要实现预期效果,咋写都无所谓吧;如果数据量很多,可能写**影响速度