So when we are dealing with SQL we join two tables with primary and foreign key relationship, which combine rows from respective table.Joins are very integral part of SQL.

The four types of join we use are:

  1. Inner Join
  2. Left Join
  3. Right Join
  4. Full Join

Basically joins are explained using Venn diagram in most of the tutorial i will follow same traditional approach as these diagram are well suited.  

Inner Join

Assume we have table 1 and table 2 inner join fetch the  matching records based on condition provided. so most of the SQL databases `JOIN`  or 'INNER JOIN' is used to perform inner join operation general syntax of inner join is

SELECT <> FROM <table>
    JOIN <table2> ON table.<id> = table2.<id> 

Left Join

Assume we have table 1 and table 2 LEFT join fetch all records from table 1 and matching records from table 2 based on condition provided. so most of the SQL databases  'LEFT JOIN' keyword is used to perform Left join operation and this type of join is also categorised as outer join general syntax of Left join is

SELECT <> FROM <table>
    LEFT JOIN <table2> ON table.<id> = table2.<id> 

Right Join

Assume we have table 1 and table 2 Right join fetch all records from table 2 and matching records from table 1 based on condition provided. so most of the SQL databases  'RIGHT JOIN' keyword is used to perform right join operation and this type of join is also categorised as outer join general syntax of Right join is

SELECT <> FROM <table>
    RIGHT JOIN <table2> ON table.<id> = table2.<id> 

FULL Join

Assume we have table 1 and table 2 full join fetch all records from table 1 and table 2.most of the SQL databases  'FULL JOIN' keyword is used to perform  join, and some sql databases might not support FULL JOIN operation

SELECT <> FROM <table>
    FULL JOIN <table2> ON table.<id> = table2.<id>