SQL INNER JOIN problem Moodle 2.8

SQL INNER JOIN problem Moodle 2.8

by Tifano T -
Number of replies: 3

Hi Moodlers,

In my query below I have put a condition (in bold) so that I can get to match an item and the badge it sits in as part of the criteria.

However, it would not show other items that are not added to the badges.

I f i remove that condition they all display, however, they don't match the completion dates of their respective badges.

Does anyone know where i would be doing wrong?

Any thought of the workaround for that is highly appreciated

Cheers

FROM

  mdl_course_modules_completion cmc


  LEFT JOIN mdl_course_modules cm

        ON (cmc.coursemoduleid =cm.id)

    LEFT JOIN mdl_course_sections cs 

        ON (cs.id = cm .section)

    LEFT JOIN mdl_modules m

        ON (m.id= cm.module )  

 LEFT JOIN mdl_course c

        ON c.id = cm.course

LEFT JOIN mdl_user u

        ON u.id = cmc.userid

LEFT JOIN mdl_badge_issued bgi

        ON bgi.userid = cmc.userid

LEFT JOIN mdl_badge bg

        ON bg.id = bgi.badgeid

LEFT JOIN mdl_badge_criteria bc

        ON bc.badgeid = bg.id

LEFT JOIN mdl_badge_criteria_param bcp

        ON bcp.critid = bc.id AND (bcp.value = cm.id)

WHERE bcp.value = cm.id

GROUP BY u.firstname


Average of ratings: -
In reply to Tifano T

Re: SQL INNER JOIN problem Moodle 2.8

by Tifano T -

Solved!

Thanks guys for your willing to help

Cheers

Average of ratings: Useful (1)
In reply to Tifano T

Re: SQL INNER JOIN problem Moodle 2.8

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers

How did you solve it?

In reply to Luis de Vasconcelos

Re: SQL INNER JOIN problem Moodle 2.8

by Tifano T -

Hi Luis,

Mapping the completed modules to the badges first did the trick. Wasn't easy but finally at least got what I wanted.

I  Joined badge tables to the module completion first.


Cheers


Average of ratings: Useful (1)