56,677
社区成员
发帖
与我相关
我的任务
分享
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.aspSELECT 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