当前位置:网站首页>MYSQL入门与进阶(十三)
MYSQL入门与进阶(十三)
2022-07-29 02:52:00 【小新爱编程】
在查询条件的位置作为条件存在
A.使⽤in
Eg1:查询考试不及格的学⽣名单
B.使⽤not in
Eg2:查询没有参加基于C语⾔理解软件编程考试的学⽣名单
– A.使用in
– Eg1:查询考试不及格的学生名单
select studentid from exam where exam<60
select * from studentinfo where studentid in(
select studentid from exam where exam<60
)
– B.使用not in
– Eg2:查询没有参加基于C语言理解软件编程考试的学生名单
select * from subject
where subjectname=‘基于C语言理解软件编程’
select studentid from exam where subjectid=1
select * from studentinfo where studentid not in(
select studentid from exam where subjectid=(
select subjectid from subject
where subjectname=‘基于C语言理解软件
编程’) )
C.使⽤all
Eg3:查询成绩⽐“C003”这⻔课程的任意成绩都⼤的学⽣考试信息。
D.使⽤any
Eg4:查询成绩⽐“C003”这⻔课程的某⼀个成绩⾼的学⽣考试信息
C.使用all:所有>all(子查询,返回值是多行一列),
如果值大于子查询结果中的所有才算true应该被显示否则不显示:>max Eg3:查询成绩比“基于C语言理解软件编程”这门课程的所有人成绩都大的学生考试信息。
select * from `subject` where subjectname='基于C语言理解软件编程'
select * from exam where subjectid=1
select * from exam where exam>all(
select exam from exam where subjectid=(
select subjectid from `subject` where subjectname='基于C语言理解软件
编程'));
select * from exam where exam>(
select max(exam) from exam where subjectid=(
select subjectid from `subject` where subjectname='基于C语
言理解软件编程'))
-- D.使用any:任意,>any(子查询) :大于子查询中任意一个值即可,>min
-- Eg4:查询成绩比“C003”这门课程的某一个成绩高的学生考试信息
select * from exam where exam>any(
select exam from exam where subjectid=(
select subjectid from `subject` where subjectname='基于C语言理解软件
编程' );
select * from exam where exam>(
select min(exam) from exam where subjectid=(
select subjectid from `subject` where subjectname='基于C语
言理解软件编程' ) );
边栏推荐
- CentOS install mysql8
- The origin of Nacos' name
- Unable to start after idea installation
- groupby 方法
- Notes on the sixth day
- Stm32c8t6 encoder motor speed measurement and Arduino photoelectric module speed measurement
- Chapter 09_ Use of performance analysis tools
- HTB-Blue
- JVM基础入门篇一(内存结构)
- 《QA离业务代码能有多近?》QA对业务代码进行可测性改造
猜你喜欢
My approval function of conference OA project
会议OA项目之我的审批功能
13_ue4进阶_蒙太奇动画实现一边走一边攻击
爆肝整理JVM十大模块知识点总结,不信你还不懂
Add a row to a specific location in the dataframe
Shell编程规范与变量
算法---粉刷房子(Kotlin)
idea配置web容器与war打包
MySQL compound query (important)
Hangao database best practice configuration tool Hg_ BP log collection content
随机推荐
解析机器人与人类情感共鸣的主观意识
FTP protocol details
MySQL large table joint query optimization, large transaction optimization, avoiding transaction timeout, lock wait timeout and lock table
Notes on the ninth day
Analyzing the subjective consciousness of emotional resonance between robots and human beings
C language: Little Lele and hexadecimal conversion
第09章_性能分析工具的使用
常用hooks总结
13_ue4进阶_蒙太奇动画实现一边走一边攻击
Multi table (Association) query of SQL query data
centos安装mysql8
Feedback function of conference OA
C language: judging letters
扫雷简单版
idea配置web容器与war打包
Day 8 notes
Comic algorithm_ Xiaohuihui interview
C#从网址异步获得json格式的数据
HTB-Blocky
TP5.0 小程序用户无需登录,直接获取用户手机号。