Dear all,
I am working on a SQL code to have a report on the users with a certain system role and members of a cohort.
This is the SQL I am using for the report on the role
SELECT ra.roleid,r.name, u.username, u.firstname, u.lastname, u.emailI am not a SQL expert so it was already a big win for me to edit this report from the "special roles"!
FROM prefix_role_assignments AS ra
JOIN prefix_role AS r ON r.id = ra.roleid
JOIN prefix_user AS u ON u.id = ra.userid
WHERE ra.roleid = 10
What shall I add to have other data? I do not understand how can I merge two different tables. I think the "FROM" function is my problem.
If I write
SELECT ra.roleid,r.name, u.username, u.firstname, u.lastname, u.email, h.idnumber, h.nameI get an error message :/
FROM prefix_role_assignments AS ra
AND prefix_cohort AS h
JOIN prefix_role AS r ON r.id = ra.roleid JOIN prefix_user AS u ON u.id = ra.userid
JOIN prefix_cohort_members AS hm ON h.id = hm.cohortid
JOIN prefix_user AS u ON hm.userid = u.id
WHERE ra.roleid = 10
Thanks in advance!