assuming these 3 tables:
student - | student_id | name | sex | - 31 students
score - | event_id | student_id | grade | - 173 total grades
event - | event_id | type | date | - 6 events
this means there could be a total of 186 entries in the grade book,
6 for every student, some or none of which could be NULL.
I am trying to understand joins by working with these tables. I am trying to join them such that I can get all the grades all the students have in all of the various quizzes/tests assigned to them. Some students don't have grades for some events and therefore wouldn't show up in a standard inner joined query (as expected). However, I want all the students to show up, NULL or not, for every event there is that all students could have taken. However I can only successfully get back data for students who have a grade recorded in the scores table. I'm not exactly sure what I'm doing wrong or where to go from here.
The query I was trying:
SELECT st.student_id, st.name, e.date, e.type, sc.score
FROM event e LEFT JOIN score sc
ON e.event_id = sc.event_id
RIGHT JOIN student st
ON sc.student_id = st.student_id
Now I think I know WHY it's not working, just not the solution around it. LEFT and RIGHT joins work on the concept that if a record in the specified table doesn't match then the appropriate NULL values will be appended where needed. However, because all students have at least one grade, technically the RIGHT JOIN is satisfied since each student has at least one matching record. I can see how modifying my join between event and score can provably solve this easily, but again, I'm just not to sure what I'm doing.