You use self-join when a table refers to data by itself.
For example, an Employee table may have a SupervisorID column that points to an employee who is the boss of the current employee.
To request data and get information for people in one line, you can independently join this:
select e1.EmployeeID, e1.FirstName, e1.LastName, e1.SupervisorID, e2.FirstName as SupervisorFirstName, e2.LastName as SupervisorLastName from Employee e1 left outer join Employee e2 on e1.SupervisorID = e2.EmployeeID
RedFilter Jul 29 '10 at 11:37 2010-07-29 11:37
source share