You are on page 1of 2

Here are to SQL-Statements which works...

First, shows the users for every course

Unset
SELECT distinct u.lastname AS Nachname, u.firstname AS
Vorname, c.fullname AS Kursname FROM (((mdl_user AS u INNER
JOIN mdl_user_enrolments AS user_enr ON u.id =
user_enr.userid) INNER JOIN mdl_enrol AS enr ON
user_enr.enrolid = enr.id) INNER JOIN mdl_course AS c ON
enr.courseid = 638) INNER JOIN mdl_course_completions AS
course_compl ON (user_enr.userid = course_compl.userid) WHERE
u.deleted=0

Last: Show the user vor a special Course (here 111)

Unset
SELECT username, idnumber, firstname, lastname, email FROM
mdl_user_enrolments ue JOIN mdl_enrol en ON ue.enrolid = en.id
JOIN mdl_user uu ON uu.id = ue.userid WHERE en.courseid = 111

Here are to SQL-Statements which works...

First, shows the users for every course

Unset
SELECT distinct u.lastname AS Nachname, u.firstname AS
Vorname, c.fullname AS Kursname FROM (((mdl_user AS u INNER
JOIN mdl_user_enrolments AS user_enr ON u.id =
user_enr.userid) INNER JOIN mdl_enrol AS enr ON
user_enr.enrolid = enr.id) INNER JOIN mdl_course AS c ON
enr.courseid = 638) INNER JOIN mdl_course_completions AS
course_compl ON (user_enr.userid = course_compl.userid) WHERE
u.deleted=0

Last: Show the user vor a special Course (here 111)


Unset
SELECT username, idnumber, firstname, lastname, email FROM
mdl_user_enrolments ue JOIN mdl_enrol en ON ue.enrolid = en.id
JOIN mdl_user uu ON uu.id = ue.userid WHERE en.courseid = 111

You might also like