mysql通过什么样的查询可以由图一三个表得到图二

qq_40341627 2017-09-21 05:55:42
...全文
186 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
academic2015 2017-10-23
  • 打赏
  • 举报
回复
select EnglishScore.strNum,students.name,EnglishScore.score as EnglishScore,MathScore.score as MathScore from students,EnglishScore,MathScore where students.id=15001 and MathScore.strnum=15001 and English.strnum=15001
凡人皆侑一死 2017-09-22
  • 打赏
  • 举报
回复
select b.stnum,a.name,b.socre as englishscore,c.score as mathscore 
from student a left join Englishscore b on a.id=b.stnum --通过student表的id跟englishscore表的stnum连接得出每个学生的英语成绩
left join mathsocre c on a.id=c.stnum    --通过student表的id跟mathscore表的stnum连接得出每个学生的数学成绩
where a.id=1
看看join语法就会明白了 http://www.w3school.com.cn/sql/sql_join.asp
二月十六 2017-09-21
  • 打赏
  • 举报
回复
SELECT  students.* ,
EnglishScore.score AS EnglishSroce ,
MathScore.score AS MathScore
FROM students
JOIN EnglishScore ON EnglishScore.stnum = students.id
JOIN MathScore ON MathScore.stnum = students.id
WHERE students.id = 15001
听雨停了 2017-09-21
  • 打赏
  • 举报
回复
select a.*,b.score as EnglishScore,c.score as MathScore from student a left join EnglishScore b on a.id=b.stnum left join MathScore c on a.id=c.stnum

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧