SELECTDISTINCT(user_id)
FROMaacgb2v5_usergroups as ug1
INNERJOINaacgb2v5_usergroupsAS ug2 ON ug2.lft>=ug1.lft AND ug1.rgt>=ug2.rgt
INNERJOINaacgb2v5_user_usergroup_mapAS m ON ug2.id=m.group_id
WHERE ug1.id IN (8)

SELECTDISTINCT(user_id)
FROMaacgb2v5_usergroups as ug1
INNERJOINaacgb2v5_usergroupsAS ug2 ON ug2.lft>=ug1.lft AND ug1.rgt>=ug2.rgt
INNERJOINaacgb2v5_user_usergroup_mapAS m ON ug2.id=m.group_id
WHERE ug1.id IN (7)

SELECT user_id, category_id, role FROMaacgb2v5_kunena_user_categoriesWHERE role IN (1,2)