4
Reply

What is a self join?

Bhasker Das

Bhasker Das

18y
6.4k
0
Reply

    Self join is join which is join against equality-LikeEmployee Id is the Id of Manager Select E.Name as E,M.Name as M from Emp Where E.id=M.idwhere

    Self join is join which is join against equality-LikeEmployee Id is the Id of Manager Select E.Name as E,M.Name as M from Emp Where E.id=M.idwhere

    Just in case, if they ask you to write query....

    TableName: T1,  Columns: EId, EName, MId

    select E1.EId as EmployeeId, E1.Ename as EmployeeName, E2.EName as ManagerName
    from T1 as E1, T1 as E2 where E1.MId = E2.EId

    Self join is just like any other join, except that two instances of the same table will be joined in the query. Here is an example: Employees table which contains rows for normal employees as well as managers. So, to find out the managers of all the employees, you need a self join.