Hi
Has anyone a ready SQL query to delete all empty groups of all courses (no members in the group)?
Thanks
MJ
All the usual disclaimers about messing around directly in the database being a good way to break your Moodle site apply.
The key tables are groups, groups_members and groupings_groups.
So probably something like
DELETE FROM mdl_groupings_groups
WHERE NOT EXISTS (
SELECT *
FROM mdl_groups_members
WHERE mdl_groupings_groups.groupid = mdl_groups_members.groupid
)
Then
DELETE FROM mdl_groupsNot tested. Probably safe. Probably, once you have done this, you then need to use Admin -> Development -> Purge caches.
WHERE NOT EXISTS (
SELECT *
FROM mdl_groups_members
WHERE mdl_groups.id = mdl_groups_members.groupid
)