SQL Server Performance

Nested Query

Discussion in 'General Developer Questions' started by Reddy, Jun 4, 2008.

  1. Reddy New Member

    I have 4 tables

    Users{userid(pk),name,no}

    GroupUsers{userid(pk),usergroupid(pk)}

    UserGroups{UserGroupid(pk),Name}

    UserGroupUserGroups{Parentusergroupid(pk),childusergroupid}

    relationships:

    FK_UserGroupUsers_Users
    FK_UserGroupUsers_UserGroups
    FK_UserGroupUserGroups_UserGroups1
    FK_UserGroupUserGroups_UserGroups



    I would like to have a view ot CTE's what ever but the result i need some thins like


    Users Groups

    X A
    X B
    Y A
    Z C
    X D

    From the result set
    X is a member of group A
    Group A is a member of Group B and so X is a member of Group A and Group B

    Here Groups has users and also sub groups has users
  2. Madhivanan Moderator

Share This Page