所以我有3张桌子:
student
-studentid
-studentname
course_offerings
-course_offeringid
-course
-type
scores
-student_studentid
-course_offering_course_offeringid
-score
当我进行查询时:
SELECT studentid, studentname, course, type, score
FROM scores
INNER JOIN student ON scores.student_studentid = student.studentid
INNER JOIN course_offering ON scores.course_offering_course_offeringid = course_offering.course_offeringid
我得到类似的输出:
studentid   studentname     course  type    score
123345      Doe, John       123     Exam 1  100
123345      Doe, John       123     Exam 2  95
123345      Doe, John       123     Exam 3  75
123345      Doe, John       123     Final   93
543211      Doe, Jane       123     Exam 1  70
543211      Doe, Jane       123     Exam 2  91
543211      Doe, Jane       123     Exam 3  99
543211      Doe, Jane       123     Final   43
.
.
.
我想要的是输出是:
studentid   studentname     course  Exam 1  Exam 2  Exam 3  Final
123345      Doe, John       123     100     95       75     93
543211      Doe, Jane       123     70      91      99      43
这可能只用 MySQL 吗?