Aside from the semicolon that made your query fail, you also should not be hard-coding the "mdl_" table prefix; you should wrap your table names in braces. So, instead of, for example, "mdl_role_assignments", write "{role_assignments}".
General developer forum
get_records_sql
This discussion has been locked so you can no longer reply to it.