Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2012-01-31 : 03:05:32
|
I have a below table Create Table Employee(ID int,Names varchar(40),Manager_ID int,Manager_name varchar(40))--------------------------------------------------insert into Employee values( 101,'A',110,'B')insert into Employee values( 110,'X',117,'Y')insert into Employee values( 117,'M',121,'N')insert into Employee values( 110,'E',131,'F')insert into Employee values( 116,'O',117,'P')---------------------------------------------------select * from EmployeeID Names Manager_ID Manager_name101 A 110 B110 X 117 Y117 M 121 N110 E 131 F116 O 117 PI need an output of 110117121131I need to fetch all the records of dependent from both the columnI tried this but no luckselect a.id from Employee a join Employee b on a.id=b.manager_IDThanks,Gangadhara MSSQL Developer and DBA |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-31 : 04:41:39
|
[code]select distinct manager_id from employee[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2012-01-31 : 20:49:45
|
No actually i need dependent value for the input column ID value.Thanks,Gangadhara MSSQL Developer and DBA |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-01-31 : 21:11:04
|
what do you mean ? can you explain further ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|