Any、All查询

1.Any:结果集中的任意一个值。
例如:select * from scott.emp where sal<any(select sal from scott.emp where job='SALESMAN');
就是在结果集中取任意值(比结果集最大的小的就可以),反之>any就是比结果集中最小的大可以。
就是只要满足这个只查询结果中任意一个就是true,否则为false;
2.All:和Any相反,>All就是比子查询结果中的所有值还要大(比最大值更大),<Any就是比最小值还小。
例如:select * from scott.emp where sal>all(select sal from scott.emp where job='SALESMAN');相当于
<wbr><wbr><wbr>select * from scott.emp where sal&gt;(select max(sal) from scott.emp where job='SALESMAN');</wbr></wbr></wbr>

反之:select * from scott.emp where sal<all(select sal from scott.emp where job='SALESMAN');相当于select * from scott.emp where sal<(select min(sal) from scott.emp where job='SALESMAN');

你可能感兴趣的:(查询)