Hi Gaurav,
I got the solution but its not working for me, any help me
SELECT c.id,c.fullname,u.lastname,r.name
FROM mdl_course c
JOIN mdl_context ct ON c.id = ct.instanceid
JOIN mdl_role_assignments ra ON ra.contextid = ct.id
JOIN mdl_user u ON u.id = ra.userid
JOIN mdl_role r ON r.id = ra.roleid
WHERE roleid= '5' AND userid = '197'
Please check in this file location : lib/coursecatlib.php
protected static function get_records($whereclause, $params) {
global $DB;
// Retrieve from DB only the fields that need to be stored in cache.
$fields = array_keys(array_filter(self::$coursecatfields));
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
$sql = "SELECT c.id,c.fullname,u.lastname,r.name
FROM mdl_course c
JOIN mdl_context ct ON c.id = ct.instanceid
JOIN mdl_role_assignments ra ON ra.contextid = ct.id
JOIN mdl_user u ON u.id = ra.userid
JOIN mdl_role r ON r.id = ra.roleid
WHERE roleid= '5' AND userid = '197'";
return $DB->get_records_sql($sql,
array('contextcoursecat' => CONTEXT_COURSECAT) + $params);
}