学生表:table t_student
字段 :StuID,StuName,StuSex,StuBirth, PK:StuID
课程表: table t_course
字段 :ClsID,ClsName,ClsHour, PK:ClsID
选课记录:table t_electivecourse
字段 :StuID, ClsID, CurScores 复合主键,StuID,ClsID
要把所有学生的选课考试成绩查询出来,我的想法是在选课记录表中 同时增加2个字段 分别是学生名字 和 课程名字,这样组成一个临时表,就查询这个临时表并且显示。
但是我只能增加1个字段,第2个字段无论如何也增加不进去,试了好久。请指点一下如何可以实现将2个字段都加进去!以下是我写的加一个字段组成临时表
select *from
(
select *,
(
select StuNamefrom t_student where t_student.StuID= t_electivecourse.StuID
) as 'sname'
from t_electivecourse
)table2