SELECT * FROM Training_Registration registration
LEFT OUTER JOIN Training_Segment segment
ON registration.referenceId = segment.id
LEFT OUTER JOIN Training_Module module
ON segment.moduleId = module.id
OR registration.referenceId = module.id
INNER JOIN Training_Course course
ON module.courseId = course.id
OR registration.referenceId = course.id
WHERE registration.traineeId = @traineeId
AND registration.registrationDate >= @startDate
AND course.courseTemplateId = @courseTemplateId
;
for this 4 table relationship.
Registration FK > Segment , Module , Course
Segment FK > Module
Module FK > Course
Course FK > CourseTemplate
I already get what the result I want, but I can't explain what happen here. I change the left out or left also can get the result. The last join is left or right or whatever also can get the result.
Can someone help me explain this MySQL Script.