SQLState: 42S22 Error Code: 207 Message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid column name 'r'. SQLState: 42S22 Error Code: 207 Message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid column name 'u'. SELECT TOP 20 * FROM ( SELECT CAST(r AS NVARCHAR(255)) + CAST(r.id AS NVARCHAR(255)) as uniqueid, r.id, r.useridfrom, r.useridto, r.subject, r.fullmessage, r.fullmessageformat, r.fullmessagehtml, r.smallmessage, r.notification, r.contexturl, r.contexturlname, r.timecreated, r.timeuserfromdeleted, r.timeusertodeleted, r.component, r.eventtype, r.timeread FROM mdl_message_read r WHERE r.notification = 1 AND r.id IN (SELECT messageid FROM mdl_message_popup WHERE isread = 1) AND r.useridto = '2' UNION ALL SELECT CAST(u AS NVARCHAR(255)) + CAST(u.id AS NVARCHAR(255)) as uniqueid, u.id, u.useridfrom, u.useridto, u.subject, u.fullmessage, u.fullmessageformat, u.fullmessagehtml, u.smallmessage, u.notification, u.contexturl, u.contexturlname, u.timecreated, u.timeuserfromdeleted, u.timeusertodeleted, u.component, u.eventtype, 0 as timeread FROM mdl_message u WHERE u.notification = 1 AND u.id IN (SELECT messageid FROM mdl_message_popup WHERE isread = 0) AND u.useridto = '2' ) f ORDER BY timecreated DESC, timeread DESC, id DESC[array ( 0 => 2, 1 => 2,)] Error code: dmlreadexception * line 479 of \lib\dml\moodle_database.php: dml_read_exception thrown * line 297 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end() * line 404 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end() * line 865 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query() * line 913 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql() * line 100 of \message\output\popup\classes\api.php: call to sqlsrv_native_moodle_database->get_records_sql() * line 111 of \message\output\popup\externallib.php: call to message_popup\api::get_popup_notifications() * line ? of unknownfile: call to message_popup_external::get_popup_notifications() * line 229 of \lib\externallib.php: call to call_user_func_array() * line 59 of \lib\ajax\service.php: call to external_api::call_external_function()