现在我有3个表
Student中有
SID 表示学号
CID 表示班号Lesson中有
LID   表示课程号
LName 表示课程名字
CID   表示课程所属班级Score中有
SID   表示这个成绩的拥有者的学号
LID   表示这个成绩所属课程
Att   分数1
Pro   分数2
Res   分数3
Rep   分数4现在想写一个sql语句来查询指定CID(班级号)和LID(课程号)的所有学生的每个成绩,就是分数1 2 3 4那个,求帮忙
下面是查询语句
select Score.SID as 学号,Student.SName as 姓名,Lesson.LName as 课程名,Score.Attendance as 出勤,Score.Process as 实验过程,Score.Result as 实验结果,Score.Report as 实验报告 from Score,Lesson,Student,Class where Class.CID=1ASP.NETSQLselect

解决方案 »

  1.   

    看下这个行不
    select XXX from Score where LID=XXX and SID in(select SID from Student where CID=XXX)
      

  2.   

    要连姓名、课程名也查出来的话,试下这个select XXX from Score,Student,Lesson where Score.LID=XXX and Score.SID in(select SID from Student where CID=XXX) and Score.LID=Student.SID and Score.LID=Lesson.LID
      

  3.   


    select Score.SID as 学号,Student.SName as 姓名,Lesson.LName as 课程名,Score.Attendance as 出勤,Score.Process as 实验过程,Score.Result as 实验结果,Score.Report as 实验报告 from Score,Lesson,Student,Class where Class.CID=1 and Lesson.CID = Class.CID and Score.LID = Lesson.LID and Score.LID = ‘你的课程号’顺便一提,你这个和.net没有什么关系,你应该去数据库区问。