当前位置:网站首页>Mysql---三张表(student,课程,分数) 查询课程为数学的学生姓名,编号,成绩
Mysql---三张表(student,课程,分数) 查询课程为数学的学生姓名,编号,成绩
2022-06-24 06:41:00 【晚风吹儿】
一、设计表
1.student表

2.subject表

3.score表

二、查询数据
需求:查询课程为数学的学生姓名,编号,成绩
方法一:
where语句查询
select student.sno,student.sname,score.score from student,subject,score where student.sno = score.sno and subject.cno = score.cno and subject.subject_name="数学";
查询结果:
方法二:
使用内连接
select 表1.字段,表2.字段,表3.字段 from 表1 inner join 表2 on 表1.字段= 表2.字段 inner join 表3 on 表1.字段=表3.字段 where 条件;
select s.sno,s.sname,c.score from student s inner join score c on s.sno=c.sno inner join subject u on c.cno=u.cno where u.subject_name="数学"

解析:
1、分别查看三个表,找到有关联的字段
2、看表可以看出,student表的sno与subject表的sno可匹配,subject表的与score表的cno匹配,所以可以通过这两个字段筛选数据
3、再加个指定科目:数学,即可把对应数据找到
边栏推荐
- FreeRTOS MPU使系统更健壮!
- A case study of apiserver avalanche caused by serviceaccount
- JVM调试工具-jmap
- Page Jump and database connection of student management system
- The P2V and V2V software starwind converter is really easy to use
- Challenges brought by maker education to teacher development
- Tencent host security captures Yapi remote code execution 0day vulnerability for wild exploitation. The attack is spreading and can be intercepted by firewall
- Research on redis High Availability Mechanism
- Go operation SQLite code error
- 【帧率倍频】基于FPGA的视频帧率倍频系统verilog开发实现
猜你喜欢

JVM调试工具-jmap

【pointNet】基于pointNet的三维点云目标分类识别matlab仿真

Spark project Packaging Optimization Practice

成为 TD Hero,做用技术改变世界的超级英雄 | 来自 TDengine 社区的邀请函

Typora charges? Build vs Code markdown writing environment

Become TD hero, a superhero who changes the world with Technology | invitation from tdengine community

大厂不是衡量能力的唯一出路,上财学姐毕业三年的经验分享

在js中正则表达式验证小时分钟,将输入的字符串转换为对应的小时和分钟
![[Yugong series] June 2022 asp Basic introduction and use of cellreport reporting tool under net core](/img/18/1576cb7bdae5740828d1db5b283aee.png)
[Yugong series] June 2022 asp Basic introduction and use of cellreport reporting tool under net core

Maui uses Masa blazor component library
随机推荐
.NET7之MiniAPI(特别篇) :Preview5优化了JWT验证(上)
应用配置管理,基础原理分析
Brief introduction of domain name registration
What is domain name resolution? What if the domain name cannot be resolved?
毕业季进击的技术
Laravel document reading notes -laravel str slug() function example
Online font converter what is the meaning of font conversion
JVM调试工具-Arthas
Laravel文档阅读笔记-Laravel Str slug() Function Example
Canal安装配置
. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)
Functions in setinterval cannot have parentheses
Virtual file system
Big factories are not the only way to measure ability. The three years' experience of Shangcai's graduation
如何删除/选择电脑上的输入法
Spark project Packaging Optimization Practice
【问题解决】虚拟机配置静态ip
Outils de débogage JVM - Arthas
How do I reinstall the system? How to install win10 system with USB flash disk?
2022蓝队HW初级面试题总结