-
SQL语言基础包括使用子查询的技巧
资源介绍
使用子查询
*
SQL> SELECT ename
2 FROM emp
3 WHERE sal >
4 (SELECT sal
5 FROM emp
6 WHERE empno=7566);
ENAME
----------
KING
FORD
SCOTT
2975
*
SELECT ename FROM emp WHERE sal >
(SELECT sal FROM emp WHERE empno=7566);
Using a Subquery
In the slide, the inner query determines the salary of employee 7566. The outer query takes the result of the inner query and uses this result to display all the employees who earn more than this amount.
Instructor Note
Execute the subquery (inner query) on its own first to show the value that the subquery returns. Then execute the outer query using the result returned by the inner query. Finally, execute the entire query (containing the subquery) and show that the result is the same.
- 上一篇: 单行子查询-SQL语言基础
- 下一篇: 配置数据库服务器参数-HDR数据库知识