Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,

Am using MSSQL Server,
In TableA, there are three fields(Userid,Username,ManagerId).

SQL
Userid  - Username - ManagerId
32    -    A    -     13
33    -    B     -    32
132    -   C     -    45
211    -   D     -    32
23     -   E     -    76
260     -  F     -    33
206    -   G     -    33
208   -    H     -    211


Now I want to query from TableA like
If UserId 32 logsin, I want to take userid(33,211) having mangaer id as 32, then to take userid(260,206,208)having managerid as 33 and 211 and so on....

Regards,
RK
Posted
Updated 21-Jun-13 3:45am
v2
Comments
damodara naidu betha 27-Jun-13 1:56am    
can you give the output format i.e how it should look like ?

1 solution

Here is the direct example for self join

http://www.aspdotnet-suresh.com/2012/07/self-join-query-in-sql-server-self-join.html[^]

Thanks
--RA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900