当前位置:网站首页> 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则此行数据被查出,接着第二行查询。。。以此往复。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持软件开发网。
边栏推荐
- I Basic concepts
- 不落人后!简单好用的低代码开发,快速搭建智慧管理信息系统
- Meta Force原力元宇宙系统开发佛萨奇模式
- Is embedded system really safe? [how does onespin comprehensively solve the IC integrity problem for the development team]
- ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
- CodeSonar如何帮助无人机查找软件缺陷?
- 静态测试工具
- How to choose financial products? Novice doesn't know anything
- When easygbs cascades, how to solve the streaming failure and screen jam caused by the restart of the superior platform?
- Tensorflow2. How to run under x 1 Code of X
猜你喜欢

Measure the height of the building

How to meet the dual needs of security and confidentiality of medical devices?

软件缺陷静态分析 CodeSonar 5.2 新版发布

OneSpin | 解决IC设计中的硬件木马和安全信任问题
Codesonar enhances software reliability through innovative static analysis

Apifox 接口一体化管理新神器

H3C S7000/S7500E/10500系列堆叠后BFD检测配置方法

Tensorflow2.x下如何运行1.x的代码

Implement secondary index with Gaussian redis

How to meet the dual needs of security and confidentiality of medical devices?
随机推荐
Small guide for rapid formation of manipulator (12): inverse kinematics analysis
Traversal of Oracle stored procedures
CodeSonar通过创新型静态分析增强软件可靠性
上海交大最新《标签高效深度分割》研究进展综述,全面阐述无监督、粗监督、不完全监督和噪声监督的深度分割方法
使用camunda做工作流设计,驳回操作
Flask1.1.4 werkzeug1.0.1 source code analysis: Routing
图扑数字孪生煤矿开采系统,打造采煤“硬实力”
开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
Introduction to referer and referer policy
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
程序猿赚的那点钱算个P啊!
EasyGBS级联时,上级平台重启导致推流失败、画面卡住该如何解决?
C语言 整型 和 浮点型 数据在内存中存储详解(内含原码反码补码,大小端存储等详解)
Cantata9.0 | 全 新 功 能
Write a jump table
Alibaba cloud award winning experience: how to mount NAS file system through ECS
【论文阅读】MAPS: Multi-agent Reinforcement Learning-based Portfolio Management System
How C language determines whether it is a 32-bit system or a 64 bit system
Precautions for cjson memory leakage
2022如何评估与选择低代码开发平台?