I am trying to create a query that will show which courses are associated with which cross listed courses. For example a student is in a course with the id number of 2710.202431 but it is also cross listed as 141202431. The query below shows both courses separately for a student. I am trying to figure out what table ties the two together.
SELECT
c.id AS courseid,
c.idnumber,
c.fullname,
u.username,
u.firstname,
u.lastname,
u.email
FROM
mdl_role_assignments ra
JOIN mdl_user u ON u.id = ra.userid
JOIN mdl_role r ON r.id = ra.roleid
JOIN mdl_context cxt ON cxt.id = ra.contextid
JOIN mdl_course c ON c.id = cxt.instanceid
WHERE ra.userid = u.id
AND ra.contextid = cxt.id
AND cxt.contextlevel =50
AND cxt.instanceid = c.id
and u.idnumber = 'blah'
ORDER BY c.fullname
5