今天使用Oracle的时候,使用scott的表进行练习的时候,子查询中使用了not in 发现没有数据显示

--查询不是领导的信息
select * from emp where empno not in (select mgr from emp);
select * from emp where empno <>all(select mgr from emp);

进过网上查询,发现是子查询中的数据有null,

  • Oracle给出的官方解释如下:

Oracle中子查询,没有数据

正确的写法是

--正确的写法
select * from emp where empno not in (select mgr from emp where mgr is not null);

相关文章: