-
这个SQL语言基础查询能否正常执行?
资源介绍
这个查询能正常工作么?
*
no rows selected
子查询不返回任何值
SQL> SELECT ename, job
2 FROM emp
3 WHERE job =
4 (SELECT job
5 FROM emp
6 WHERE ename='SMYTHE');
*
SELECT ename, job FROM emp WHERE job =
(SELECT job FROM emp WHERE ename='SMYTHE');
Problems with Subqueries
A common problem with subqueries is no rows being returned by the inner query.
In the SQL statement on the slide, the subquery contains a WHERE (ename='SMYTHE') clause. Presumably, the intention is to find the employee whose name is Smythe. The statement seems to be correct but selects no rows when executed.
The problem is that Smythe is misspelled. There is no employee named Smythe. So the subquery returns no rows. The outer query takes the results of the subquery (null) and uses these results in its WHERE clause. The outer query finds no employee with a job title equal to null and so returns no rows.
- 上一篇: Robo3T1.1.1
- 下一篇: Mongo 3T带破解码