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 |
shinelawrence
Starting Member
32 Posts |
Posted - 2013-10-04 : 07:25:51
|
Hi Everyone, how to use self join like this scenario.Table:Empid Empname ManagerID1 Arul Null2 Satya 13 feddy 14 Lawce 2I need to get the o/p:Empid Empname Manager1 Arul Null2 Satya Arul3 feddy Arul4 Lawce Satya.... How to get...Pls tell the solution.Thanks & AdvancedLawce |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-04 : 07:41:32
|
just include table once more in joinSELECT t1.Empid, t1.Empname, t2.Empname AS ManagerFROM Table t1LEFT OUTER JOIN Table t2On t2.Empid = t1.managerID ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
shinelawrence
Starting Member
32 Posts |
Posted - 2013-10-04 : 08:02:10
|
thank u very much....Lawce |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-04 : 08:51:02
|
you're welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|