文件名称:在多行子查询中使用Any操作符-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2024-05-15 13:25:02
SQL 基础
在多行子查询中使用Any操作符
*
EMPNO ENAME JOB
--------- ---------- ---------
7654 MARTIN SALESMAN
7521 WARD SALESMAN
SQL> SELECT empno, ename, job
2 FROM emp
3 WHERE sal < ANY
4 (SELECT sal
5 FROM emp
6 WHERE job = 'CLERK')
7 AND job <> 'CLERK';
950
800
1100
1300
*
SELECT empno, ename, job FROM emp WHERE sal < ANY
(SELECT sal FROM emp WHERE job = 'CLERK') AND job <> 'CLERK';
Multiple-Row Subqueries (continued)
The ANY operator (and its synonym SOME operator) compares a value to each value returned by a subquery. The slide example displays employees whose salary is less than any clerk and who are not clerks. The maximum salary that a clerk earns is $1300. The SQL statement displays all the employees who are not clerks but earn less than $1300.