Not sure the title accurately reflects what I need to do and this question is possibly out of the scope of Stack Overflow as I do not have much to work with, other than my problem. I will explain my scenario ...
I have a reporting web application. There are three levels of users Senior Managers, Managers and Team Members. Each Manager is responsible for a team. Each Senior Manager is responsible for a subset of Managers.
Senior Managers and Managers write a report on their subordinates. Currently the system only allows Manager to view reports on their immediate subordinates. However the system is to be adapted to allow Senior Managers to view reports on their Managers as well as view any reports the Managers have written about their team members.
I have table team_members table which governs which team a user is in. So ...
Users
--------
uid
forename
surname
team_members
------------
id
leader_id
member_id
leader_id and member_id relate to the primary key of the users table; uid.
So as a Senior Manager I need to be able to generate a list of all immediate team members (Managers), plus a list of their subordinates. Is there a way to do this within one query?