当前位置:网站首页> 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则此行数据被查出,接着第二行查询。。。以此往复。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- 深度学习模型压缩与加速技术(七):混合方式
- 智能软件分析平台Embold
- Micro service remote debug, nocalhost + rainbow micro service development second bullet
- AADL inspector fault tree safety analysis module
- Deep learning model compression and acceleration technology (VII): mixed mode
- Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry
- Static analysis of software defects codesonar 5.2 release
- 【解决】package ‘xxxx‘ is not in GOROOT
- CodeSonar如何帮助无人机查找软件缺陷?
- 复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
猜你喜欢
不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
Measure the height of the building
Klocwork 代码静态分析工具
Implement secondary index with Gaussian redis
Network principle (1) - overview of basic principles
Codesonar enhances software reliability through innovative static analysis
使用高斯Redis实现二级索引
大厂经典指针笔试题
[philosophy and practice] the way of program design
How does codesonar help UAVs find software defects?
随机推荐
4G设备接入EasyGBS平台出现流量消耗异常,是什么原因?
Helix QAC 2020.2新版静态测试工具,最大限度扩展了标准合规性的覆盖范围
机械臂速成小指南(十二):逆运动学分析
Introduction to referer and referer policy
Network principle (1) - overview of basic principles
Onespin | solve the problems of hardware Trojan horse and security trust in IC Design
Update iteration summary of target detection based on deep learning (continuous update ing)
I Basic concepts
取两个集合的交集
凌云出海记 | 易点天下&华为云:推动中国电商企业品牌全球化
TS quick start - Generic
Tensorflow2. How to run under x 1 Code of X
H3C s7000/s7500e/10500 series post stack BFD detection configuration method
Implement secondary index with Gaussian redis
Spark judges that DF is empty
Deep learning model compression and acceleration technology (VII): mixed mode
不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
智能软件分析平台Embold
Implement secondary index with Gaussian redis
Flask1.1.4 Werkzeug1.0.1 源码分析:路由