查询每门课程被选修的学生数
1.没动脑子直接写出的命令【冗余,student表多余】
select c.cname,c.cid,count(*) as 个数 from student a
join score b on b.sid=a.sid
left join course c on c.cid=b.cid
group by cid ;
2.思考后的命令语句
select c.cid,c.cname,count(*) as 个数
from course c
join score a on a.cid=c.cid
group by cid ;