SQL Joins are one of the most used functionalities while writing the SQL Queries. They are the clause used to combine rows from two or more tables based on the common/related column between the participating tables. Various joins are used in the SQL Query.
Types of Join
- INNER JOIN
Inner Join is the Default join in the Query. It retrieves the Common records from the Joining Tables.
2. OUTER JOIN
A. LEFT OUTER JOIN
Retrieves data Matching data from Joining Tables as well as remaining data from the Left Table.
B. RIGHT OUTER JOIN
Retrieves data Matching data from Joining Tables as well as remaining data from the Right Table.
- FULL JOIN
This join retrieves all the data from both Left and Right Tables.
To Make it easier Let’s take a pictorial example
In this Example,
Inner Join will give: 4, 5
Left Outer Join will give: 1, 2, 3, 4, 5
Right Outer Join will give: 4, 5, 6, 7, 8
Full Outer Join/Full Join will give: 1, 2, 3, 4, 5, 6, 7, 8
Summary of Joins
To make it more clear
Using Tables to explain the joins
LEFT OUTER JOIN
RIGHT OUTER JOIN
FULL OUTER JOIN
I Hope it was helpful.
The article was collected and written by Bijaya Subedi. Bijaya is currently working as an ETL tester in a DC/VA based Mortgage Company.