在多行子查询中使用Any操作符-SQL语言基础

时间:2021-04-25 19:38:22
【文件属性】:
文件名称:在多行子查询中使用Any操作符-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2021-04-25 19:38:22
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. ANY means more than the minimum. =ANY is equivalent to IN. Instructor Note When using SOME or ANY, you often use the DISTINCT keyword to prevent rows from being selected several times.

网友评论