登录 注册
当前位置:主页 > 资源下载 > 在SQL语言基础中,运用Any操作符于多行子查询场景

在SQL语言基础中,运用Any操作符于多行子查询场景

  • 更新:2024-07-07 12:07:14
  • 大小:5.26MB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Informix - 数据库
  • 格式:PPT

资源介绍

在多行子查询中使用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.