mysql多表操作2 多表查询
来源:互联网 发布:淘宝木子禅佛珠怎么样 编辑:程序博客网 时间:2024/05/17 02:44
多表的定义:mysql多表操作1以及存储过程的应用
表中的信息:
学生表:
教师表:
课程表:
选课表(成绩表):
(1)查询选了课的学生所有信息:
select * from studentwhere id in(select Sid from SC);结果:
(2)查询成绩已经出来了的学生的全部信息:
成绩没出来默认为null
select *from student where id in( select Sid from SC where score is not null);结果:
查询学号为“B1000”的学生选了多少门课
select count(*) as 课程数 from SCwhere Sid="B1000";
结果:
查询学号为“B1000”的学生选了哪些课程
select Cname from course where cid in( select Cid from SC where Sid="B1000");
结果:
查询学号为“B1000”的学生选了那些课程的老师信息
select * from teacherwhere Tid in( select Tid from course where Cid in ( select Cid from SC where Sid="B1000" ));结果:
查询选修了C++这门课的学生姓名:
select name as 姓名 from studentwhere id in(select Sid from SCwhere Cid in(select Cid from coursewhere Cname="C++语言"));结果:
阅读全文
0 0
- MySQL多表查询的基本操作
- mysql多表操作2 多表查询
- MySQL数据记录基本操作——多表查询、子查询和正则表达式查询
- MySQL数据记录基本操作——多表查询、子查询和正则表达式查询
- Mysql 多表查询基本操作 第五更
- 多表查询操作
- 多表查询操作
- 【MySQL】MySQL多表查询
- MySQL 多表查询
- mysql多表查询
- Mysql多表查询
- MySQL多表查询
- MYSQL多表查询
- MySQL多表查询
- MySQL多表查询
- MySQL多表查询
- MySQL多表查询
- MySQL多表查询
- OpenStack octavia 详解
- jdk1.8 J.U.C并发源码阅读------AQS之独占锁的获取与释放
- API学习java.lang.Object.equals
- 百练1481:Maximum sum
- web.xml中servlet ,filter ,listener ,interceptor的作用与区别
- mysql多表操作2 多表查询
- [笔记]随手写写画画(1)
- Luogu 1588(dfs)(false)
- get请求后台获取时乱码解决方法
- 对jdk和jre的理解
- YOLO选择出只有某一类的检测框并将框保存在txt中
- opencv CvMat数组调用函数后计算值出错可能的问题
- API学习java.lang.Object.hashCode
- Springboot-async