带any嵌套查询
select emp.empno,emp.ename,emp.sal from scott.emp where sal>any(select sal from scott.emp where job='manager');
等价于
select sal from scott.emp where job='manager' 结果为 sal:2975 2850 2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal>2975 or sal>2850 or sal>2450
带some嵌套查询
select emp.empno,emp.ename,emp.sal from scott.emp where sal=some(select sal from scott.emp where job='manager');
等价于
select sal from scott.emp where job='manager' 结果为 sal:2975 2850 2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal=2975 or sal=2850 or sal=2450
注:any与some是等价的
带all嵌套查询
select emp.empno,emp.ename,emp.sal from scott.emp where sal>all(select sal from scott.emp where job='manager');
等价于
select sal from scott.emp where job='manager' 结果为 sal:2975 2850 2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal>2975 and sal>2850 and sal>2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal>any(select sal from scott.emp where job='manager');
等价于
select sal from scott.emp where job='manager' 结果为 sal:2975 2850 2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal>2975 or sal>2850 or sal>2450
带some嵌套查询
select emp.empno,emp.ename,emp.sal from scott.emp where sal=some(select sal from scott.emp where job='manager');
等价于
select sal from scott.emp where job='manager' 结果为 sal:2975 2850 2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal=2975 or sal=2850 or sal=2450
注:any与some是等价的
带all嵌套查询
select emp.empno,emp.ename,emp.sal from scott.emp where sal>all(select sal from scott.emp where job='manager');
等价于
select sal from scott.emp where job='manager' 结果为 sal:2975 2850 2450
select emp.empno,emp.ename,emp.sal from scott.emp where sal>2975 and sal>2850 and sal>2450