嗨,我正在为以下数据库结构编写一个 mysql 查询。
Professor (EMP ID,Name,Status,Salary,Age)
Course(Course ID,Course Name,Points)
Works(Course ID,EMP ID,Class ID)
Assumptions:
Each course has only one instructor in each semester
Status can take values from “Full”, “Associate”, and “Assistant”
我需要执行以下操作。
返回在一堂课中至少教过两门课程的正教授的姓名
SELECT p.name
FROM professor p, works w
WHERE p.empid = w.empid
AND p.status = ‘full’
AND w.classid IN (SELECT classid
FROM works
WHERE count(courseid)>1)
返回在 Class 10 中教授课程数量最多的教授的姓名
SELECT p.names
FROM professor p, works w
WHERE p.empid =w.empid
AND w.classid IN (SELECT classid
FROM works
WHERE classid = 10
AND coursed = max(coursed))
但是这些查询返回错误的结果。我是mysql新手,请帮忙。