Help with mdl_course_sections

Help with mdl_course_sections

by Nicole Stone -
Number of replies: 1

I'm having an issue with joining course_sections to course_modules. 

Select * from mdl_course_sections cs where cs.course=10318;  --- This returns 27 sections

Select * from mdl_course_modules cm where cm.course=10318; --- This only returns 3 sections


Why wouldn't all of the cs.id numbers exist in the course_modules table? From my research the join should be as follows: 

Select * from mdl_course_sections cs
Join mdl_course_modules cm on cm.section=cs.id

What am I missing here?





Average of ratings: -
In reply to Nicole Stone

Re: Help with mdl_course_sections

by T Thakar -

Hi

Course modules are the resources that you have added to a course. From what you have provided I think you have only 3 resources added to a course and there are 27 sections..


if you run this query 

Select * from mdl_course_sections cs LEFT Join mdl_course_modules cm on cm.section=cs.id

you will get all the sections and show each course modules..


e.g. if you have 2 modules in 1 section then you will see the section multiple times.

if you have only one or no modules in a section then you will only see it once.


Hope this helps