我正在尝试通过查询获取学生的分数和成绩,但我无法计算出联接。这是一个非常复杂的数据库。以前有人做过吗?
下面的查询(我自己修改的表格)适用于某些学生,但不适用于其他学生,所以我需要一个具有原始表结构的合适的查询。
谢谢
我的错误查询
SELECT mdl_grade_items.id AS ItemID,
mdl_course.shortname AS CourseShortname,
mdl_grade_items.itemname AS ItemName,
mdl_grade_items.grademax AS ItemGradeMax,
mdl_grade_items.aggregationcoef AS ItemAggregation,
mdl_grade_grades.finalgrade AS FinalGrade,
mdl_user.username AS StudentID,
mdl_user.id
FROM mdl_grade_items
INNER JOIN mdl_grade_grades
ON mdl_grade_items.id = mdl_grade_grades.itemid
INNER JOIN mdl_role_assignments
ON mdl_grade_grades.userid = mdl_role_assignments.userid
AND mdl_grade_items.courseid = mdl_role_assignments.mdlcourseid
INNER JOIN mdl_course
ON mdl_course.id = mdl_grade_items.courseid
INNER JOIN mdl_user
ON mdl_user.id = mdl_role_assignments.userid
WHERE mdl_grade_items.courseid = '2864'
AND mdl_user.username = '123456789'