当查询的结果来源于有关系的多张表时,需要使用到连接查询
select students.sname,sum(scores.score)
from scores
inner join students on scores.stuid=students.id
group by students.sname;
select subjects.stitle,avg(scores.score),max(scores.score)
from scores
inner join subjects on scores.subid=subjects.id
where subjects.isdelete=0
group by subjects.stitle;
原文:https://www.cnblogs.com/Elite-Wang/p/14204463.html