当前位置:网站首页>Oracle-子查询
Oracle-子查询
2022-06-29 07:40:00 【旷世奇才李先生】
工欲善其事必先利其器
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

文章目录
一、子查询
exists():判断,如果子查询有返回数据,那么就执行外部查询
1、查询学生中年龄最小的学生信息
select * from student where age = (select min(age) from student);
2、查询年龄和“张三”一样大的学生信息
select * from student where age = (select age from student where name = '张三')
3、查询年龄,性别和“张三”一样的学生信息,不包括“张三”
select * from student where (age,sex) = (select age,sex from student where name = '张三')
and name <> '张三'
4、查询年龄和“张三”或者“李四”相同的学生信息
select * from student where age in (select age from student where name ='张三' or '李四')
5、如果有姓名为“张三”的学生,那么就查询出所有学生信息,如果没有姓名为“张三”的学生,就什么都不查询
select * from student where exists(select * from student where name = '张三')
二、在having中使用子查询
1、查询出班级平均分高于年级平均分的班级、平均分、班级人数
select class,count(*),avg(grade) from student group by class having avg(grade) > (select avg(grade) from student)
三、在from子句中使用子查询
1、查询学生id和老师进行班级分组后的sid相等的学生id
select s.id from student s (select t.id,t.class from teacher t group by t.class) where s.id = t.sid
四、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- 【6G】算力网络技术白皮书整理
- Hook 简介
- [eye of depth wuenda machine learning homework class phase IV] regularization regularization summary
- js:Array. Reduce cumulative calculation and array consolidation
- 《乔布斯传》英文原著重点词汇笔记(七)【 chapter five】
- Friends, static keywords, static methods, and relationships between objects
- Django - installing mysqlclient error: mysqlclient 1.4.0 or newer is required; you have 0.9.3
- 变形金刚Transformer详解
- Excel中VLOOKUP函数简易使用——精确匹配或近似匹配数据
- 壁纸小程序源码双端微信抖音小程序
猜你喜欢
笔记本电脑快速连接手机热点的方法
![Speech synthesis: overview [generation task of unequal length sequence relation modeling]](/img/13/bd9def50f0efde49b622d139f63a83.png)
Speech synthesis: overview [generation task of unequal length sequence relation modeling]

Stm32 usart+dma usage based on Hal Library

Simple use of vlookup function in Excel -- exact matching or approximate matching data

华为设备配置中型网络WLAN基本业务

Code:: blocks code formatting shortcuts

蓝图基础

U盘内存卡数据丢失怎么恢复,这样操作也可以

华为云的AI深潜之旅

Soliciting articles and contributions - building a blog environment with a lightweight application server
随机推荐
自动化运维管理平台——spug的搭建和日常使用
一个高频问题,三种模型思维来破解此风控难题
NP3 formatted output (I)
php 清除多维数组里面的空值
A high-frequency problem, three kinds of model thinking to solve this risk control problem
x86和x64的区别
華為雲的AI深潜之旅
Simple use of AWS elastic Beanstalk
A review of visual SLAM methods for autonomous driving vehicles
MySQL中有哪些约束?(实例验证)
dcase_util教程
苹果开发者容易招致调查的若干行为
Segment tree and use
Debugging nocturnal simulator with ADB command
Notes mosaïque
NLP annotation tool: label studio realizes multi-user collaborative marking
消息中间件:pulsar
【LoRaWAN节点应用】安信可Ra-08/Ra-08H模组入网LoRaWAN网络的应用及功耗情况
Use GPU training in the cloud on the laboratory (take yolov5 as an example)
Matlab 用法