- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
exists和not exists用法(Exists and not exists)
exists和not exists用法(Exists and not exists)
Exists (SQL returns the result set for real)
Not exists (SQL does not return the result set, true)
As follows:
Table A
ID NAME
1 A1
2 A2
3 A3
Table B
ID AID NAME
11 B1
22 B2
32 B3
Table A and B is 1 to many relationship A.ID = B.AID
SELECT, ID, NAME, FROM, A, WHERE, EXIST (SELECT * FROM, B, WHERE, A.ID=B.AID)
Execution results are
1 A1
2 A2
The reasons can be analyzed as follows
SELECT, ID, NAME, FROM, A, WHERE, EXISTS (SELECT * FROM, B, WHERE, B.AID=1)
I SELECT B WHERE B.AID=1 * FROM value, returns true, so the data
SELECT, ID, NAME, FROM, A, WHERE, EXISTS (SELECT * FROM, B, WHERE, B.AID=2)
I SELECT B WHERE B.AID=2 * FROM value, returns true, so the data
SELECT, ID, NAME, FROM, A, WHERE, EXISTS (SELECT * FROM, B, WHERE, B.AID=3)
I SELECT B WHERE B.AID=3 * FROM value, return false, so there is no data
NOT EXISTS is the other way round
SELECT, ID, NAME, FROM, A, WHERE, NOT, EXIST (SELECT * FROM, B, WHERE, A.ID=B.AID)
Execution results are
3 A3
===========================================================================
EXISTS = IN, which means the same, but there is a slight difference in syntax, as if the use of IN efficiency is too close, and should not be the reason for indexing
SELECT, ID, NAME, FROM, A, WHERE, ID, IN (SELECT, AID, FROM, B)
NOT EXISTS = NOT IN, which means the same, but a little grammatical difference
SELECT, ID, NAME, FROM, A, WHERE, ID, NOT, IN, (SELECT, AID, FROM, B)
================================================================================================================
EXISTS:
The system requires SQL optimization, the efficiency of the lower SQL optimization, so that it is more efficient operation, which requires part of the in/not in SQL modified to exists/not exists
The modification method is as follows:
Ins SQL statement
SELECT, ID, category_id, htmlfile, title,, convert (varchar (20), begintime, 112) as pubtime
FROM, tab_oa_pub, WHERE, is_check=1, and
Category_id in (select, ID, from, tab
您可能关注的文档
- 美女白领交际中的五大陷阱(Five big traps in the social intercourse of beautiful women and white-collar workers).doc
- 美学原理作业要求(Principles of aesthetics).doc
- 美学原理答案--网络课程--美学原理--网络课程(The answer to aesthetic principles -- Network Course -- Aesthetics Principle -- Network Course).doc
- 美国进步教育运动的理论家--杜威(Dewey, a theorist of progressive education movement in the United States).doc
- 美学原理答案(Principles of aesthetics).doc
- 美容师行为规范(Beautician code of conduct).doc
- 美学基本知识(Basic knowledge of aesthetics).doc
- 美容院接待顾客的标准(A standard for receiving customers in a beauty salon).doc
- 美容师要学会成功的冥想法(Beautician should learn the meditation method of success).doc
- 美日等国高价进口中国非转基因大豆不仅吃还做药(Japan and the United States and other countries to import Chinese non GM soybeans at high prices not only to eat, but also to make medicine).doc
- EXCLE 透视表制作(EXCLE perspective watch).doc
- Fanuc系统G代码表(Fanuc system G code table).doc
- FANUC系统攻丝(FANUC system tapping).doc
- FANUC系统(FANUC system).doc
- FATE 老虎道场 远坂凛篇剧情(The story of the FATE of the FATE tiger daoban).doc
- FB代表什么电子器件(What electronic devices does FB stand for).doc
- FC 经典游戏大回顾之RPG(FC classic game review RPG).doc
- FC-757AT全自动高频天线调谐器(Fc-757at automatic hf antenna tuner).doc
- FC游戏 创世纪英雄(魔神英雄传)的攻略和秘籍(The strategy and secret of the genesis hero of the FC game).doc
- Fate Stay Night全解(Fate Stay Night).doc
文档评论(0)