in与exist
来源:互联网 发布:vue.js文件下载和上传 编辑:程序博客网 时间:2024/06/05 11:30
select * from table_a a where a.id in (select b.id from table_b b);
select * from table_a a where exists(select b.id from table_b b where a.id=b.id);
如上两个查询语句,in语句只执行了一次,它查出b表中的所有id字段并缓存起来。然后,检查a表的id是否与b表中的id相等,如果相等则将a表的记录加入结果集中,直到遍历完a表的所有记录.exists()会执行a.length次,它并不缓存exists()结果集,因为exists()结果集的内容并不重要,重要的是结果集中是否有记录,如果有则返回true,没有则返回false.
一般的in适用于b表数据量较小的情况,exists适用于a表数据量较小的情况。
0 0
- exist 与 in
- 数据库in与exist
- in与exist
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist,not in 与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- in与exist , not in与not exist 的区别
- gitlab 安装 备份 恢复 邮箱配置 修改web端口
- Longest Consecutive Sequence
- XML基础
- <稀缺-我们是如何陷入贫穷与忙碌的> 摘要
- 数字图像处理的基础
- in与exist
- 开始使用Android Sutdio(三)创建一个Hello World程序
- Tesseract-OCR 进行文字识别 VS2010及不安装opencv,就可以使用opencv
- hive subprocess failed with code X 的错误码对应信息
- Android开发响应检测及内存分析 - 【StrictMode】
- Linux源代码软件的安装与卸载
- 将博客搬至51CTO
- c++判断图片格式
- HBase基本数据操作详解