【发布时间】:2015-12-24 19:20:46
【问题描述】:
查询 1
select ename,deptno
from emp1
where exists
(select deptno from dpt where dpt.deptno=emp1.deptno AND deptno>20);
返回与施加在子查询中的 deptno 字段上的条件相对应的 ename
查询 2
select ename,deptno
from emp1
where exists
(select deptno from dpt where deptno>20);
但在查询 2 中,结果包含字段 ename 和 deptno 的所有值
是什么改变了两个查询中的结果集?是因为连接吗?联接实际上如何在查询 1 中带来不同的结果集?为什么在查询 1 中考虑 where 条件而不在查询 2 中考虑?
legends:
empname is employee name in the table emp,
deptno is department no. which is the common field in emp and dept tables.
【问题讨论】:
标签: sql oracle oracle11g sqlplus