SQL Query that includes both teachers and students

SQL Query that includes both teachers and students

by Juan F -
Number of replies: 0
Good morning!  I am interested in creating a query that includes both teachers and students.  I have been able to write a query that returns almost everything I need except for teacher name.  See below for the query.  I would appreciate any suggestions on how to incorporate the teacher name into this query.


SELECT 
c.shortname AS "Course Name",
concat( u.firstname, " ", u.lastname ) AS "Student Name",
gi.itemmodule AS "Assignment Type",
gi.itemname AS itemname,
gi.grademax AS itemgrademax

FROM mdl_user u
JOIN mdl_grade_grades g ON g.userid = u.id
JOIN mdl_grade_items gi ON g.itemid =  gi.id
JOIN mdl_course c ON c.id = gi.courseid

WHERE c.category = 497
AND (c.shortname LIKE '%ACC%' OR c.shortname LIKE '%BUS%')
AND u.deleted <> 1
Average of ratings: -