多行子查询-SQL语言基础

时间:2021-04-25 19:38:22
【文件属性】:
文件名称:多行子查询-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2021-04-25 19:38:22
SQL 基础 多行子查询 * 操作符 IN ANY ALL 含义 等于列表中的某一个值 与列表中的任意值比较 与列表中的所有值相比较 返回值多于一行 使用多行比较操作符 * Multiple-Row Subqueries Subqueries that return more than one row are called multiple-row subqueries. You use a multiple-row operator, instead of a single-row operator, with a multiple-row subquery. The multiple-row operator expects one or more values. Example Find the employees who earn the same salary as the minimum salary for departments. The inner query is executed first, producing a query result containing three rows: 800, 950, 1300. The main query block is then processed and uses the values returned by the inner query to complete its search condition. In fact, the main query would look like the following to the Oracle Server: SQL> SELECT ename, sal, deptno 2 FROM emp 3 WHERE sal IN (SELECT MIN(sal) 4 FROM emp 5 GROUP BY deptno); SQL> SELECT ename, sal, deptno 2 FROM emp 3 WHERE sal IN (800, 950, 1300);

网友评论