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 |
|
madhukar
Starting Member
3 Posts |
Posted - 2002-05-21 : 04:59:49
|
| Hi , I have a table schema like this.. EmployeeId Name managerId 1 ABC <NULL> 2 XYZ 1 3 PQR 1 4 MNO 3 5 STU 4 Here managerId and EmployeeId are related.Can I have a query for this table so that if I give a manager name then I have to get all the employees under him (Like a organisation tree). for Eg.:- If I give 'ABC' as manager then I have to get alll the records in the table shown above. Thanks Madhukar Hebbar M |
|
|
karthikms
Starting Member
1 Post |
Posted - 2002-05-21 : 06:02:10
|
| Try this.select lpad(' ',2*(level-1)) || name name from <table name> start with name = '<manager name>' connect by prior employeeid = managerid;Regards,Karthik. |
 |
|
|
madhukar
Starting Member
3 Posts |
Posted - 2002-05-21 : 07:24:19
|
| Doesn't work with sql server. Anything else in SQl Server.. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|
|