当前位置:网站首页>Oracle 限制时将空值排除
Oracle 限制时将空值排除
2022-08-09 07:26:00 【白露-】
1.Oracle特性
Oracle有个特性,就是在限制时,会将空值也排除在外:
例如:
select '小黑'name,'2'class from dual
union all select '小白'name,'0'class from dual
union all select '小红'name,'1'class from dual
union all select '小绿'name,'4'class from dual
union all select null name,'5' class from dual
如果排除小黑,那么会得到这样的数据:
select * from (select '小黑'name,'2'class from dual
union all select '小白'name,'0'class from dual
union all select '小红'name,'1'class from dual
union all select '小绿'name,'4'class from dual
union all select null name,'5' class from dual)where name<>'小黑'
数据库在排除小黑这条数据的同时,也将class为5的数据也排除掉了
2.解决
问题也很好解决,只需要在限制后面添加or name is null,即可:
select * from (select '小黑'name,'2'class from dual
union all select '小白'name,'0'class from dual
union all select '小红'name,'1'class from dual
union all select '小绿'name,'4'class from dual
union all select null name,'5' class from dual)where name<>'小黑' or name is null
边栏推荐
- 解决pycharm每次新建项目都要重新pip安装一些第三方库等问题
- SA-Siam:用于实时目标跟踪的双重连体网络A Twofold Siamese Network for Real-Time Object Tracking
- 4.MySQL更新和删除数据
- Zero shift of leetcode
- pip安装更换镜像
- 2019南昌网络赛 C题,Hello 2019
- tianqf's problem-solving ideas
- 【机器学习】降维代码练习
- Codeforces Round #359 (Div. 2) C. Robbers' watch Violent Enumeration
- Variable used in lambda expression should be final or effectively final报错解决方案
猜你喜欢
随机推荐
2022年7月小结
更改Jupyter Notebook默认打开目录
Change Jupyter Notebook default open directory
way of thinking problem-solving skills
Inception V3 Eye Closure Detection
View log common commands
MongDb query method
2022 年全球十大最佳自动化测试工具
SiamFC:用于目标跟踪的全卷积孪生网络 fully-convolutional siamese networks for object tracking
Apache POI
CoCube传感器MPU6050笔记
Tkinter可以选择的颜色
【模板】树链剖分 P3384
金九银十即将到来,求职套路多,面试指南我来分享~
细谈VR全景:数字营销时代的宠儿
4.MySQL更新和删除数据
分布式事务产生的原因
高项 01 信息化与信息系统
failed (13: Permission denied) while connecting to upstream
子路由及路由出口配置