当前位置:网站首页> Mysql子查询关键字的使用方式(exists)
Mysql子查询关键字的使用方式(exists)
2022-07-07 18:38:00 【1024问】
1. all
1.1 格式
1.2 特点
1.3 操作
2. any(some)
1.1 格式
1.2 特点
1.3 操作
3. in
1.1 格式
1.2 特点
1.3 操作
4. exist
1.1 格式
1.2 特点
1.3 操作
1.4 解释
1. all1.1 格式all:与子查询返回的所有值比较为true则返回true
all可以与=,>=,>,<,<=,<>结合使用,分别表示等于,大于等于,大于,小于,小于等于,不等于其中的所有数据
大于all表示指定列中的值必须要大于子查询集中的每一个值,即必须要大于子查询集的最大值;如果是小于即小于子查询中的最小值。
1.3 操作any:与子查询返回的所有值比较为true则返回true
any可以与=,>=,>,<,<=,<>结合使用,分别表示等于,大于等于,大于,小于,小于等于,不等于其中的任何一个数据
大于any表示指定列中的值必须要大于子查询集中的任何一个值,即必须要大于子查询集的最小值;其他同理
some可以理解为any的别名
1.3 操作in用于判断某个记录的值,是否在指定的集合中
在in关键字前边加上not可以将条件反过来
1.3 操作该子查询如果“有数据结果”(至少返回一行数据),则该EXISTS()结果为:true,外层查询执行
该子查询如果“没有数据结果”(没有任何数据返回),则该EXISTS()结果为:false,外层查询不执行
EXISTS后面的子查询不返回任何实际数据,只返回真或假,当返回真时where条件成立
注意:EXISTS关键字,比IN关键字的运算效率高,因此,在实际开发中,特别是大数据量时,推荐使用EXISTS关键字
1.3 操作外层查询进行查询时,外层查询会一行一行执行,第一行执行时,判断子查询是否为true,为true则此行数据被查出,接着第二行查询。。。以此往复。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- Onespin | solve the problems of hardware Trojan horse and security trust in IC Design
- Small guide for rapid formation of manipulator (12): inverse kinematics analysis
- Apifox 接口一体化管理新神器
- One click deployment of any version of redis
- 智能软件分析平台Embold
- Codesonar enhances software reliability through innovative static analysis
- 不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
- 阿里云有奖体验:如何通过ECS挂载NAS文件系统
- Micro service remote debug, nocalhost + rainbow micro service development second bullet
- Try the tuiroom of Tencent cloud (there is an appointment in the evening, which will be continued...)
猜你喜欢
H3C s7000/s7500e/10500 series post stack BFD detection configuration method
Splicing and splitting of integer ints
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
Nebula Importer 数据导入实践
ISO 26262 - 基于需求测试以外的考虑因素
一. 基础概念
最新版本的CodeSonar改进了功能安全性,支持MISRA,C ++解析和可视化
写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
Small guide for rapid formation of manipulator (11): standard nomenclature of coordinate system
Don't fall behind! Simple and easy-to-use low code development to quickly build an intelligent management information system
随机推荐
如何满足医疗设备对安全性和保密性的双重需求?
Écrivez une liste de sauts
Solve the problem of incomplete display around LCD display of rk3128 projector
Validutil, "Rethinking the setting of semi supervised learning on graphs"
How to implement safety practice in software development stage
Machine learning notes - explore object detection datasets using streamlit
Implement secondary index with Gaussian redis
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
Static analysis of software defects codesonar 5.2 release
Measure the height of the building
Guava multithreading, futurecallback thread calls are uneven
[award publicity] issue 22 publicity of the award list in June 2022: Community star selection | Newcomer Award | blog synchronization | recommendation Award
Codesonar enhances software reliability through innovative static analysis
【解决】package ‘xxxx‘ is not in GOROOT
【C语言】指针进阶---指针你真的学懂了吗?
Implement secondary index with Gaussian redis
H3C s7000/s7500e/10500 series post stack BFD detection configuration method
开发一个小程序商城需要多少钱?
字符串中数据排序
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your