All Groups associated with all categories

Require assistance with below query

  • Per category all groups which have access to the category
    - for all categories in the forum

Would something like this do the job:

SELECT 
    cg.category_id,
    g.name AS "Group Name",
    CASE 
      WHEN cg.permission_type = 1 THEN 'Create'
      WHEN cg.permission_type = 2 THEN 'Reply'
      WHEN cg.permission_type = 3 THEN 'See'
    END AS "Permission"
FROM category_groups cg
  JOIN groups g ON g.id = cg.group_id
ORDER BY cg.category_id
2 Likes