1 Star 1 Fork 0

Qianfa01/MySQL

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
son_select.txt 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
Qianfa01 提交于 2023-05-28 21:13 . son_select
#1、自查询返回值
#2、where 子句中:
#单值 返回低于平均成绩的信息:
select avg(score) from choose;
select student_no,course_no,score from choose
where score < (select avg(score) from choose);
#多值 返回没有开设课程的老师信息;
insert into teacher values('005','林老师','1110000005');
select t.*
from teacher t left join course c
on t.teacher_no = c.teacher_no
where c.teacher_no is null;
select * from teacher
where teacher_no not in (select teacher_no from course);
select * from classes
where class_no not in (select class_no from student where class_no is not null);
#2、from 子句中:
select 语句可以看成一个是虚拟的内存表;可以在此基础上进一步筛选;
select table_schema, count(*) cnt
from information_schema.tables
group by table_schema
having cnt > 50;
select * from
(select table_schema,count(*) cnt from information_schema.tables
group by table_schema) db
where cnt > 50;
select student_no,avg(score) avg_score from choose
group by student_no;
select c.student_no,c.course_no,c.score,a.avg_score
from (select student_no,avg(score) avg_score from choose
group by student_no) a, choose c
where c.student_no = a.student_no
and c.score < a.avg_score;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qianfa01/my-sql.git
[email protected]:qianfa01/my-sql.git
qianfa01
my-sql
MySQL
master

搜索帮助