- 1、本文档共25页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Errors with Subqueries One common error with subqueries is more than one row returned for a single-row subquery. In the SQL statement on the slide, the subquery contains a GROUP BY clause, which implies that the subquery will return multiple rows, one for each group it finds. In this case, the result of the subquery will be 4400, 6000, 2500, 4200, 7000, 17000, and 8300. The outer query takes the results of the subquery (4400, 6000, 2500, 4200, 7000, 17000, 8300) and uses these results in its WHERE clause. The WHERE clause contains an equal (=) operator, a single-row comparison operator expecting only one value. The = operator cannot accept more than one value from the subquery and therefore generates the error. To correct this error, change the = operator to IN. 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 clause. Presumably, the intention is to find the employee whose name is Haas. The statement is correct but selects no rows when executed. There is no employee named Haas. 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 ID equal to null, and so returns no rows. If a job existed with a value of null, the row is not returned because comparison of two null values yields a null, therefore the WHERE condition is not true. 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. SELECT last_name, salary, department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id); Example Find the employees who earn the same salary as
您可能关注的文档
- 九年度级数学上册 6.4池塘里有多少条鱼课件 北师大版.ppt
- 大学英语1期末考试考前辅导.ppt
- 052 对多处文本格式进行统一设置.pptx
- 06 урок.ppt
- 第七篇 中国古代其它珍贵文物.ppt
- ch5_变电站微机故障录波.ppt
- 古代历史(先秦).doc
- 山居秋暝简化本.ppt
- 唯美图文辑五.doc
- 武科大流体力学习题答案201108-附件.doc
- 2023-2024学年广东省深圳市龙岗区高二(上)期末物理试卷(含答案).pdf
- 2023-2024学年贵州省贵阳市普通中学高一(下)期末物理试卷(含答案).pdf
- 21.《大自然的声音》课件(共45张PPT).pptx
- 2023年江西省吉安市吉安县小升初数学试卷(含答案).pdf
- 2024-2025学年广东省清远市九校联考高一(上)期中物理试卷(含答案).pdf
- 广东省珠海市六校联考2024-2025学年高二上学期11月期中考试语文试题.pdf
- 2024-2025学年语文六年级上册第4单元-单元素养测试(含答案).pdf
- 2024-2025学年重庆八中高三(上)月考物理试卷(10月份)(含答案).pdf
- 安徽省安庆市潜山市北片学校联考2024-2025学年七年级上学期期中生物学试题(含答案).pdf
- 贵州省部分校2024-2025学年九年级上学期期中联考数学试题(含答案).pdf
文档评论(0)