What is the difference between self join and inner join?

Hi Community,

I would like to know the main difference between self join and inner join.
Can someone please help me understand in a practical way.

Thanks in Advance :slight_smile:

SQL Self Join

A self join is a regular join, but the table is joined with itself.
taken from: SQL Self Join
Example: How to get other matched value in a separate column in a Datatable? Please Help - #3 by ppr

For inner Join have a look here:

Hi!

INNER JOIN ( also reffered as JOIN ) is a JOIN of two or more tables that returns the rows that satisfy the given join condition.
SELF JOIN is a JOIN of a table to itself which returns the rows from the table that satisfy the given join condition.

You could have two tables:
( Employee {ID, Name, DepartmentID},
Department {Department ID, DepartmentName}).
You need to find the name of the department that the employees with a certain Department ID work in. For this you’ll use the JOIN between the two tables.
Now if you want to find the Employees that have the same name, you could use a SELF JOIN on the Employee table.

Hope this helps!

1 Like

Hi,

I couldn’t see any self join in drop down list of Join Data Table.

yes this type is discrete not offered. But when using the same datatable on left and right side it can be modelled, depenending to the specific scenario