查询定义:
选择艺术成绩85或以上的学生,
以及
任何计算机课程成绩85或以上的
学生
select Students.StudFirstName,Student_Schedules.Grade
from
(Select Distinct Students.StudentID,Students.StudFirstName,Student_Schedules.Grade
from (((Students
Inner Join Student_Schedules
On Student_Schedules.StudentID = Students.StudentID)
Inner Join Classes
On Classes.ClassID = Student_Schedules.ClassID)
Inner Join Subjects
On Subjects.SubjectID = Classes.SubjectID)
Inner Join Categories
On Subjects.CategoryID = Categories.CategoryID
where Categories.CategoryDescription = 'Art' and Student_Schedules.Grade >= 85)
As Stud_Art
上面的代码提取了艺术成绩85或以上的学生
Inner Join
(Select Distinct Students.StudentID,Students.StudFirstName,Student_Schedules.Grade
from (((Students
Inner Join Student_Schedules
On Student_Schedules.StudentID = Students.StudentID)
Inner Join Classes
On Classes.ClassID = Student_Schedules.ClassID)
Inner Join Subjects
On Subjects.SubjectID = Classes.SubjectID)
Inner Join Categories
On Subjects.CategoryID = Categories.CategoryID
WHERE Categories.CategoryDescription LIKE '%Computer%' AND Student_Schedules.Grade >= 85)
As Stud_CS
以上代码提取计算机成绩85或以上的学生
On Stud_CS.StudentID = Stud_Art.StudentID;
上面的代码匹配来自 Art and Computer 的 StudentID
来自 MySQLWorkBench 的错误:
错误代码:1054。“字段列表”中的未知列“Students.StudFirstName”
上述查询可以通过 SubQuery 技术解决,但我想了解如何使用 Inner Join 技术