当前位置:网站首页>Exclude null values ​​when Oracle limits

Exclude null values ​​when Oracle limits

2022-08-09 07:33:00 The millennium -

1.Oracle特性

Oracle有个特性,just when limited,Null values ​​are also excluded:
例如:

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

在这里插入图片描述

If you exclude black,Then you will get data like this:

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<>'小黑'

在这里插入图片描述
The database excludes the data of Xiaohei at the same time,也将class为5data were also excluded

2.解决

The problem is also solved very well,Just add it after the limitor 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

在这里插入图片描述

原网站

版权声明
本文为[The millennium -]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090725557108.html