diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php
index <HASH>..<HASH> 100644
--- a/mod/glossary/sql.php
+++ b/mod/glossary/sql.php
@@ -109,7 +109,7 @@
             $where = '';
         }
 
-        $sqlselect  = "SELECT ge.id, $usernamefield $as pivot, u.id uid, ge.*";
+        $sqlselect  = "SELECT ge.id, $usernamefield $as pivot, u.id as uid, ge.*";
         $sqlfrom    = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
         $sqlwhere   = "WHERE ge.userid = u.id  AND
                              (ge.approved != 0 $userid)
Merged from MOODLE_<I>_STABLE: Fix for postgres-invalid-sql (must have AS between field and alias)