日期:2014-05-17  浏览次数:20499 次

sql语句,Repeater数据显示问题
本帖最后由 chb42270589 于 2013-01-07 15:08:06 编辑


  teracher table
teacherId  teacherName
1          李四
2    王五
  student table
studentId  studentName  teacherId
1     学生1  1  
2     学生2        1  
3     学生3        1  
4           学生4  2
   scores  table
scoreId    courseName   grade   level studentId 
1     数学         80       2   1
2           数学         90       1   1
3     数学         95       1   1
4           英语         65       3   4

用Repeater显示出

李四
学生1
数学  90,95            level:1

李四
学生1
数学   80               level:2

李四
学生2


李四
学生3
 
现在我写了下面这句只能找出学生1的所有成绩
select * from scores where studentId in (select  studentId from student where teacherId in(select teracherId from teracher where teacherName='李四'))
不知道怎么好显示
public class Scores
    {

        public int ScoreId  { get; set; }

        public string CourseName { get; set; }

        public int Grade { get; set; }

        public int Level { get; set; }

        public bool StudentId  { get; set; }

    }
求指点类和sql语句应该如何写才能获得我想要的数据


排版错乱了,不知道怎么回事,希望有人能帮忙

------解决方案--------------------
哥们 你指定查找的是 李四这人的资料了 肯定就只有一条了 名字为李四的就只有一个
------解决方案--------------------
with teacher(teacherId,teacherName)
as(
select 1,'李四' union all
select 2,'王五'),
student(studentId,studentName,teacherId)
as(
select 1,'学生1',1 union all
select 2,'学生2',1 union all
select 3,'学生3',1 union all
select 4,'学生4',2),
scores(scoreId,courseName,grade,level,studentId)
as(
select 1,'数学',80,2,1 union all
select 2,'英语',90,1,1 union all
select 3,'数学',95,1,1 uni