Oracle中的not in null, in null
假设有一张这样的表:
其中,第六行的name_x为空。
那么能不能把不为空的查出来呢?
试试,我们第一瞬间就想出来的SQL:
select * from test_1 where name_x not in null;
--执行
结果:发现查不出任何的数据
同样 select * from test_1 where name_x in null; 也查不出任何数据。
所以,如果遇到 in null 或者 not in null 的时候。就会出现没数据。
当然,此处的null可能会以一个子查询的形式出现。因为子查询中也是可能会出现空值的。