MySQL SELF JOIN

If a Table is joined to itself using one of the join types, then such a type of join is called SELF JOIN.

To demonstrate MySQL SELF JOIN, let us create an Employee table with data as shown in the following image by executing the following script:

mysql-self-join-example-table

EXAMPLE: Now if we need to get the name of all the Employees with their Manager names, then we have to Join Employee Table to itself as shown in the below script. As both Employee and his/her Manager details are present in the same employee table.

RESULT:
mysql-self-join-example-result

Leave a Reply

Your email address will not be published. Required fields are marked *