我想使用内部联接来列出学生每周的学生ID,姓名和时间表总时数,当时学生每周工作时间超过4小时。
我这里需要三张桌子,student,studentReg和roomBooking如下
student
id | fname | surname | courseCode
studentReg
sID | modCode
roomBooking
bookingID | roomCode | moduleCode | dayReq | timeReq | semester | classSize
到目前为止我的SQL查询是
SELECT COUNT(moduleCode) AS [Lecture Hours],
id, fname, surname
FROM (student INNER JOIN studentReg ON student.id = studentReg.sID
INNER JOIN roomBooking ON studentReg.modCode = roomBooking.moduleCode)
HAVING COUNT (moduleCode) > 4;
当我尝试运行它时,我在表达式"
中得到了#34;语法错误任何人都可以帮我解决问题所在吗?
答案 0 :(得分:2)
永远不确定ms访问中的嵌套连接,但我会尝试类似的东西
SELECT COUNT(moduleCode) AS [Lecture Hours],
id, fname, surname
FROM student
INNER JOIN (studentReg
INNER JOIN roomBooking ON studentReg.modCode = roomBooking.moduleCode)
ON student.id = studentReg.sID
GROUP BY id, fname, surname
HAVING COUNT (moduleCode) > 4
或者
SELECT COUNT(moduleCode) AS [Lecture Hours],
id, fname, surname
FROM (student INNER JOIN studentReg ON student.id = studentReg.sID)
INNER JOIN roomBooking ON studentReg.modCode = roomBooking.moduleCode
GROUP BY id, fname, surname
HAVING COUNT (moduleCode) > 4;