- 1、本文档共25页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
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
- 国际商贸城1号线延线等8条道路市政工程(一二期)金牛区天龙大道中段工程环评报告.doc
- 绿地集团成都蜀峰房地产开发有限公司商业用房、绿化工程及附属设施(绿地东村8号地块项目一期)环评报告.doc
- 嘉兴美森医用材料有限公司年产功能性伤口敷料2亿贴新建项目环评报告.doc
- 成都润馨堂药业有限公司保健食品生产线二期2#生产车间项目环评报告.docx
- 岱山县海塘安澜工程(秀山、长涂片海塘)环境影响评价报告表.docx
- 成都中新西南物流有限公司西南物流中心四期(3号地块)项目验收监测报告表.docx
- 四川新绿色药业科技发展有限公司中药配方颗粒及川穹系列提取物高技术产业化项目环评报告.doc
- 成都市益州大道有轨电车示范线工程环评报告.docx
- 杭州海久投资管理有限公司厂房改扩建环评报告.doc
- 成都天府新区投资集团有限公司天府中央公园(一期)环评报告.docx
文档评论(0)