SQL -Structured Query Language - SQL Joins - Full Join Tutorial
Full Join is a combination of records from Left Join and Right Join.
Left Join or Left Outer Join is used to retrieve all the records from the left table ( table which is mentioned first – table1) and the records that are matched from the right table( table which is mentioned second – table2).
Right Join or Right Outer Join is used to retrieve all the records from the right table ( table which is mentioned second – table2) and the records that are matched from the left table( table which is mentioned first – table1).
We can perform full joins in multiple tables.
The syntax for full joins is-
SELECT column_name1,column_name2,..,column_nameN
FROM
table_1 FULL JOIN table_2
ON
table_1.column_name = table_2.column_name;
For example-
SELECT user_name,email ,salary
FROM
user_detail FULL JOIN user_salary
ON
user_detail.id = user_salary.id;
Better to use AS (Alias) for the long table name-
SELECT user_name,email ,salary
FROM
user_detail AS ud FULL JOIN user_salary AS us
ON
ud.id = us.id;
Here we will get a combination of record which we retrieve using Left and Right Outer Join.