有两个表如下图所示,如果要查询选修了课号为'102'的课程的所有学生的学号,姓名,性别,成绩。
如果这样写:
select sno, sname, sex from student where sno =(select sno from score where cno =102);
那成绩表的成绩要怎么一起打印出来呢?


有两个表如下图所示,如果要查询选修了课号为'102'的课程的所有学生的学号,姓名,性别,成绩。
如果这样写:
select sno, sname, sex from student where sno =(select sno from score where cno =102);
那成绩表的成绩要怎么一起打印出来呢?


可以使用联表查询:
select stu.sno, stu.sname, stu.sex, score.grade
from student stu
left join score score on stu.sno=score.sno
where score.cno=102;