A self-join is a query in which a table is joined to itself.Self-joins are used to compare values in a column with other values in the same column in the same table.
ex:
----------------------------------------------------
empID Name ManagerID
----------------------------------------------------
1 John NULL
2 Steve 1
3 Billgates 1
4 Ozzy 2
5 Homer 3
-----------------------------------------------------
if we want to display all the employees with their Managers names.In this scenario we can use self-join
ex:
----------------------------------------------------
empID Name ManagerID
----------------------------------------------------
1 John NULL
2 Steve 1
3 Billgates 1
4 Ozzy 2
5 Homer 3
-----------------------------------------------------
if we want to display all the employees with their Managers names.In this scenario we can use self-join
No comments:
Post a Comment