amrigo
08-07-2008, 05:04 PM
Hi
I have a students table and i need to clean the table from the students that have no courses
The enrolment happens at the role_assignments table the course key is related to the context table wich is related to the role-assignments table
And also just the students with the auth value = db
user
----
id
name
role
----
id
name
context
-------
id
instanceid (relates to course)
course
-------
id
fullname
role_assignments
----------------
roleid (relates to role: "student, teacher")
userid(relates to user)
contextid (relates to context)
This query brings the users who have any enrolment in a course
SELECT u.email from user u
inner join role_assignments ra on ra.userid=u.id
inner join role r on r.id=ra.roleid
inner join context ct on ra.contextid=ct.id
inner join course c on c.id=ct.instanceid
WHERE u.auth='db' AND r.id=5
Thank´s inadvance
I have a students table and i need to clean the table from the students that have no courses
The enrolment happens at the role_assignments table the course key is related to the context table wich is related to the role-assignments table
And also just the students with the auth value = db
user
----
id
name
role
----
id
name
context
-------
id
instanceid (relates to course)
course
-------
id
fullname
role_assignments
----------------
roleid (relates to role: "student, teacher")
userid(relates to user)
contextid (relates to context)
This query brings the users who have any enrolment in a course
SELECT u.email from user u
inner join role_assignments ra on ra.userid=u.id
inner join role r on r.id=ra.roleid
inner join context ct on ra.contextid=ct.id
inner join course c on c.id=ct.instanceid
WHERE u.auth='db' AND r.id=5
Thank´s inadvance