This join returns only the rows where there is a match between the columns in both tables.
Imagine you have a list of employees and a list of their salaries. If you do an inner join, you’ll only get the rows where there’s a matching employee in both lists.
For example, if you have:
Employee: (Emp_Name, City)
Employee_Salary: (Emp_Name, Department, Salary)
Employee.Emp_Name
Employee.City
Employee_Salary.Salary
Hari
Pune
10000
Om
Mumbai
7000
Jai
Solapur
5000
Outer Join:
Outer joins include rows from one table even if there are no matches in the other table.
There are two types of outer joins: left outer join and right outer join.
a. Left Outer Join:
This includes all rows from the left table (the first table mentioned) and matching rows from the right table.
If there’s no match in the right table, it fills in with NULL values.
For example, if you run:
Employee.Emp_Name
Employee.City
Employee_Salary.Salary
Hari
Pune
10000
Om
Mumbai
7000
Jai
Solapur
5000
Suraj
null
null
b. Right Outer Join:
This is similar to the left outer join but includes all rows from the right table (the second table mentioned).
If there’s no match in the left table, it fills in with NULL values.