Moodle cohorts – SQLQuery to show all global groups in which a user is inserted

Solution for Moodle cohorts – SQLQuery to show all global groups in which a user is inserted
is Given Below:

for a special Moodle-Workflow i need an SQL Query that tells me in which global groups (cohorts) a user with ID 100 is assigned or inserted. Who can help? Thanks a lot everyone for help.

Assuming your database prefix is default mdl_ :

SELECT c.* FROM mdl_cohort_members cm LEFT JOIN mdl_cohorts c ON (c.id = cm.cohortid) WHERE cm.userid = 100