SQL FULL JOIN is used to combine all the rows of two tables.

It is the combination of both left and right joins and it returns NULL if no matchings are found in either left or right table.

 

The syntax for FULL JOIN is

SELECT column_name(s)
FROM table1
FULL JOIN table2
ON table1.column_name=table2.column_name;

                                                          Or

SELECT column_name(s)
FROM table1
FULL  OUTER JOIN table2
ON table1.column_name=table2.column_name;


Example

Let us consider an example

1.Employee table

IdEmployee_NameEmpl_AgeMonthly package
1Sushil2218000
2Bhargav3245000
3Mohanthy2625000
4Nithin3852000

 

2.Payment Table

IdEmployee_NameEmpl_AgeMonthly package
1Sushil2218000
2Bhargav3245000
3Mohanthy2625000
4Nithin3852000

 

Now applying FULL JOIN on the tables

SELECT ID, Employee_Name, Amount, Payment_ID
FROM Employee
FULL JOIN Payment
ON Employee.ID=Payment.Employee_ID;

 

The result table will be as follows:

Employee_IDEmployee_NameAmountPayment_ID
1Sushil2500150
2Bhargav5000151
3MohanthyNULLNULL
4Nithin6500152