I'm trying to create a report using mysql which when a user logs in it takes their id number and gives them a list of all categories that they Department Head for. This department head is a role which can only be assigned to a category. at the moment I've been able to show a list of the user and tie it to the role eg.
SELECT usr.firstname, usr.lastname , role.description, ra.id
FROM mdl_role_assignments as ra
JOIN mdl_user as usr on usr.id = ra.userid
JOIN mdl_context as ctx on ctx.id = ra.contextid
JOIN mdl_role as role on role.id = ra.roleid
WHERE ra.id = 10 and ra.contextid = 77
where 10 is the department head role and context 77 is I think category context. and it gives me something like
Kieran Briggs - Head of Department - 10
but I can't then get the list of departments which contain that person.
Can anyone help me tie the role to the category please?
Thanks
Kieran Briggs