当前位置:网站首页>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
边栏推荐
猜你喜欢
DSP+ARM+FPGA高速PCIE/千兆网口信号仿真介绍
01 自然语言处理NLP介绍
买口罩(0-1背包)
高项 03 项目立项管理
错误:为 repo ‘oracle_linux_repo‘ 下载元数据失败 : Cannot download repomd.xml: Cannot download repodata/repomd.
XILINX K7 FPGA+RK3399 PCIE驱动调试
jmeter concurrency and some limitations of the press
PyTorch中 torch.nn与torch.nn.functional的区别
postgresql窗口功能
(本章节完结)排序第五节——非比较排序(计数排序+基数排序+桶排序)(附有自己的视频讲解)
随机推荐
MYSQLWorkbench看数据库ER图
Apache POI
DSP+ARM+FPGA高速PCIE/千兆网口信号仿真介绍
eyb:Redis学习(2)
日期处理,字符串日期格式转换
XILINX K7 FPGA+RK3399 PCIE驱动调试
【机器学习】降维代码练习
线程API
训练好的深度学习模型,多种部署方式
细谈VR全景:数字营销时代的宠儿
P1505 [National Training Team] Tourism Tree Chain Breakdown
【Template】Tree Chain Segmentation P3384
Lottie系列二:高级属性
pytorch指定GPU
链表专项练习(四)
【Docker】Docker安装MySQL
MUV LUV EXTRA 2019CCPC Qinhuangdao Station J Question KMP
Learning Notes---Machine Learning
MVN 中配置flyway mysq
长沙学院2022暑假训练赛(一)六级阅读