【问题标题】:join Query on attribute of association tablejoin 查询关联表的属性
【发布时间】:2011-12-28 01:24:05
【问题描述】:

表一:Student

id (PK)
name

表 2:`课程

id (PK)
name

表 3:StudentCourse(学生与课程之间的关联)

student_id
course_id
grade
PK(student_id, course_id)

要查找学生姓名和该学生所修的每门课程的成绩为“F”的课程名称,SQL 查询将是什么?

【问题讨论】:

  • quatro 专业版?微软作品样式表?或访问 mdb ?....什么 DATABASE ?
  • 您的意思是那些在他/她的所有课程中获得“F”的学生完全显示该学生的任何行,还是您的意思是应该只显示“F”级课程在其他课程中获得其他成绩的学生?

标签: sql database


【解决方案1】:
select distinct ss.student_id,NAME  from StudentCourse  ss JOIN  students ON ss.student_id = students.id  where not exists
(
select course_id from StudentCourse  where  student_id = ss.student_id and grade<>'f'
)  

【讨论】:

    猜你喜欢
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多