oracle not in (1,3,null)等价于id!=1 and id!=3 and id!=null,NULL与其他值做=或!=比较结果都是UNKNOWN,所以最终没有查出数据
最新推荐文章于 2022-12-07 22:50:55 发布

梓沂 于 2020-03-26 14:34:33 发布
4、not in条件中包含NULL值的情况
zx@TEST>select * from t_in where id not in (1,3,null);
no rows selected
上面查询的where条件等价于id!=1 and id!=3 and id!=null,根据上面的规则,NULL与其他值做=或!=比较结果都是UNKNOWN,所以整个条件就相当于FALSE的,最终没有查出数据。
从执行计划中查看优化器对IN的改写
https://blog.51cto.com/hbxztc/1905515
原文写的很好,想知道怎么从执行计划中查看优化器
相关知识
MySQL优化之索引优化
MySQL优化系列(三)
《Oracle编程艺术:深入理解数据库体系结构(第3版)》试读:1.3 开发数据库应用的正确(和不正确)方法
MySQL优化笔记(三)
【计算机毕业设计】017网上花店的设计与实现
网上花店设计+vue毕业设计(源码+lw+部署文档+讲解等)
数据库基础操作
mysql从表中获取用户最高出价
花店卖花系统课程设计
网上花卉购物系统
网址: oracle not in (1,3,null)等价于id!=1 and id!=3 and id!=null,NULL与其他值做=或!=比较结果都是UNKNOWN,所以最终没有查出数据 https://m.huajiangbk.com/newsview334782.html