MySQL query to get a list of Site Admin users

The following SQL will help you see which users are site admins in a MySQL (or MariaDB) database using the find_in_set function to query the values listed in the mdl_config siteadmins key-value.

select
    u.* 
from 
    mdl_user u
where 
    find_in_set(u.id, (select value from mdl_config where name = 'siteadmins'))

Note you need to use find_in_set and NOT in as it doesn’t handle the commas returned to separate each siteadmin’s user ID.