The SQL JOIN query is used to combine two or more tables based on common column name to retrieve record from all that tables.
Types of SQL JOIN Command :
There are 4 types of JOIN Command are used in SQL Server.
1- Inner join.
2- Left join.
3- Right join.
4- Full outer join.
Inner join
In SQL Inner join there are common record from all table is retrieved based on condition

Left join :
In SQL in Left join all the record from Left table is selected and the common record from Right table are selected base on condition.

Right join :
In SQL Server in Right join all the record from right table and common record of left table is execute.

Full outer join :
Full outer join retrieve all record from each tables which are connected with SQL statement.

Example :
There are two tables ‘Customer’ and ‘Salesman’ are as-
Customer : 

Salesman : 

Inner Join :
Following the statement select the common record from both table base on common column name i.e. ‘salesman_id’ is in both tables.
select * from Customer inner join Salesman on Customer.salesman_id=Salesman.salesman_id;

Left join :
Following the statement select all data from Left table ‘Customer’ and common data from Right table
select * from Customer left join Salesman on
Customer.salesman_id=Salesman.salesman_id;

Right join
The following statement select all record form Right table ‘Salesman’ and the common record from Left table ‘Customer’.
select * from Customer right join Salesman on
Customer.salesman_id=Salesman.salesman_id;

Full outer join :
The following SQL statement select all the record from Left table ‘Customer’ and Right table ’Salesman’.
select * from Customer full outer join Salesman on
Customer.salesman_id=Salesman.salesman_id;

Leave your comment