当前位置:网站首页>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、再加个指定科目:数学,即可把对应数据找到
边栏推荐
- 云监控系统 HertzBeat v1.1.0 发布,一条命令开启监控之旅!
- Win11怎么设置让CPU性能全开?Win11CPU怎么设置高性能模式?
- System design: partition or data partition
- 年中了,准备了少量的自动化面试题,欢迎来自测
- How to register the cloud service platform and what are the advantages of cloud server
- .NET7之MiniAPI(特别篇) :Preview5优化了JWT验证(上)
- 超宽带脉冲定位方案,UWB精准定位技术,无线室内定位应用
- 【帧率倍频】基于FPGA的视频帧率倍频系统verilog开发实现
- Are internal consultants and external consultants in SAP implementation projects difficult or successful? [English version]
- 内网学习笔记(4)
猜你喜欢

关于取模数据序号定位的说明 区码定位是指GBK编码

MFC使用控制台时 项目路径中不能有空格和中文,否则会报错误 LNK1342 未能保存要编辑的二进制文件的备份副本等

如何删除/选择电脑上的输入法

年中了,准备了少量的自动化面试题,欢迎来自测

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

Application of intelligent reservoir management based on 3D GIS system

Win11怎么设置让CPU性能全开?Win11CPU怎么设置高性能模式?

LuChen technology was invited to join NVIDIA startup acceleration program

智能视觉组A4纸识别样例

. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)
随机推荐
多传感器融合track fusion
RealNetworks vs. Microsoft: the battle in the early streaming media industry
[binary number learning] - Introduction to trees
JVM调试工具-Arthas
展锐芯片之GPU频率
OMX initialization process
Spark参数调优实践
App management platform app host
Become TD hero, a superhero who changes the world with Technology | invitation from tdengine community
MAUI使用Masa blazor组件库
. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)
Bay area enterprises quick look! The focus of the data regulations of Shenzhen Special Economic Zone just released is coming!
雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!
Precipitation of architecture design methodology
Computing power and intelligence of robot fog
Arduino融资3200万美元,进军企业市场
c#:互斥锁的使用
JVM調試工具-Arthas
System design: partition or data partition
An example of MySQL accidental deletion recovery - using Myflash