gr from emp); selectename from emp e where exists (select 0 from emp where mgr = e.empno); 不过,当逻辑被转变成使用NOT IN和NOT EXISTS时,问题就出现了,这两个语句会返回不同的行(第一个查询会返回0行;第二个返回意想的数据-它们是不同的查询): selectename from emp where empno not in (select mgr from emp); selectename from emp e where not exists (select 0 from emp where mgr =e.empno); NOT IN子句实际上与用=比较每一个值相同,如果任何一个测试为FALSE 或NULL的话,它就会失败。例如: select 'true' from dual where 1 not in (null,2); 页码:[1] [2] [3] [4] [5] [6] 第4页、共6页 |