180416
select 1 from dual where null != null;
select 1 from dual where null is null;
楚青岚
SQL> select distinct mgr from emp where mgr is not null; MGR ---------- 7839 7782 7698 7902 7566 7788 已选择6行。
用distinct可以找到不重复记录,
select distinct mgr from emp where mgr is not null;
上面这条语句的功能可以找到所有老板。很明显King(7839)是包括在里面的,为什么select * from emp where empno not in(select mgr from emp where mgr is not null)得到的记录不包括King而只是全部非老板员工呢?那是因为对比查找的时候,King这个人并没有被排除,当用他的empno对比上面6个数据时,自然会匹配到7839(King),从而被排除。故最终结果只会输出8个非老板员工(即全部员工剪去上面6个老板员工)。
神殇月4327540
根据你的提问,我猜告诉你这个你就明白了,oracle中空值都比较特殊,不能直接用"="或"<>"号来比较,空值既不在等于的集内,也不在不等于的集内。