결과 :그래서 내가 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에서만 가능합니까?
나는 그것이 가능할 것이라고 생각한다. 그것이 당신이 가지고있는 완벽한 테이블 구조인가? course_offering과 score table 모두에서 당신이 studentid를 잃어 버렸다고 생각합니다. – mCube
나는 학생의 점수가'점수 '에 있다고 생각하고'공물'표에 학생증이있을 이유가 없다. – kirelagin
네, 맞습니다. 미안합니다. 나는 또한 당신이 "유형"필드를 제거하고 "점수"테이블에 배치하는 것이 좋습니다. – mCube