Self join is used when one wants to refer data from the same table. Consider a scenario where we have an Employee table. Each record consist of ManagerID which is again an Employee. Now if we want to get the record of employee-manager relationship.
Consider a class Employee as,
We will create a list of Employee( I am using class, you can fetch records from database table)
Now to query data, self join is written as,
Using this query you can select child employee as well as parent employee i.e. employee as well as Manager.