当前位置:网站首页>MYSQL入门与进阶(十二)
MYSQL入门与进阶(十二)
2022-07-29 02:52:00 【小新爱编程】
在查询条件的位置作为条件存在
通过=引⼊的⼦查询,必须返回单个值。只能匹配⼀⾏。值是⼀个,但是可以组合
如果确保只有⼀⾏⼀列的返回值即值只有⼀个,那么可以= > < >= <= in not in也⾏
Eg:查找和谭明同⼀城市的学⽣信息
Eg2:查找最低分的所有学⽣信息
– 子查询:查询结果作为检索条件的比对值存在
– 查询和马钰一个城市的学生信息
select city from studentinfo where studentname=‘马钰’
select * from studentinfo where city=‘商丘’
– =匹配,必须保证子查询返回的值只有一行一列
select * from studentinfo where city=(select city from studentinfo where
studentname=‘马钰’)
– > < != in(可以有多行范围) not IN
– 查询最低分的学生信息
select min(exam) from exam
select * from exam where exam=45
select * from studentinfo where studentid=‘2011001011’
select * from studentinfo where studentid=(
select studentid from exam where exam=(
select min(exam) from exam ) )
IN 、ANY 、ALL 的⽐较运算符引⼊的列表上操作的⼦查询(可以返回多列)
如果返回值是多⾏的情况下:不能使⽤=> <这些,可以⽤in not in >anyall <all这些关键字
-- 查询最低分的学生信息:如果最低分只有一个人,那么可以=
-- 如果是多个人,必须用in
select min(exam) from exam
select * from exam where exam=45
select * from studentinfo where studentid in('2011001011','2011001003')
select * from studentinfo where studentid in(
select studentid from exam where exam=(
select min(exam) from exam
)
)
边栏推荐
- DHCP protocol detailed analysis
- Etcd implementation of large-scale service governance application practice
- Day 10 notes
- 解析Steam教育中的项目式学习创造力
- 《QA离业务代码能有多近?》通过codediff直接暴露缺陷
- Double for loop
- Add a row to a specific location in the dataframe
- K210 - sound source location and sound recognition
- OWT server source code analysis (4) -- video module analysis of mixer out
- 多线程实现多用例文件并发读取执行+Selenium Grid4实现测试框架分布式部署
猜你喜欢

C language: judging letters

Notes on the seventh day

IDEA安装后无法启动

Chapter 09_ Use of performance analysis tools

Confusion matrix learning notes

Linux下安装MySQL8.0的详细步骤
![[opencv] use OpenCV to call mobile camera](/img/66/6207bafbc9696e43da7a60a386a238.jpg)
[opencv] use OpenCV to call mobile camera

Look at robot education and lead the mainstream of quality education

K210 - sound source location and sound recognition

Add a row to a specific location in the dataframe
随机推荐
VIM common commands
OSPF experiment
sqlilabs less-32~less-33
vasp计算任务报错:M_divide:can not subdivide 8 nodes by 6
Some new ideas about time complexity
Flink kernel source code (VII) Flink SQL submission process
JVM基础入门篇一(内存结构)
idea配置web容器与war打包
Available data sets for scene classification tasks (part)
Confusion matrix learning notes
并发模式之单例和不变模式
【FreeSwitch开发实践】UniMRCP编译与安装
Unable to start after idea installation
Idea replaces the contents of all files
.NET 序列化枚举为字符串
Mysql复合查询(重要)
【机器人学习】机械臂抓手matlab运动学与admas动力学分析
C language: Little Lele and hexadecimal conversion
Verilog的时间系统任务----$time、$stime、$realtime
解析Steam教育中的项目式学习创造力