All for Joomla All for Webmasters

SQL FULL JOIN

The SQL full join is the result of combination of both left and right outer join and the join tables have all the records from both tables. It puts NULL on the place of matches not found.

SQL full outer join and SQL join are same. generally it is known as SQL FULL JOIN.

SQL full outer join:

What is SQL full outer join?

SQL full outer join is used to combine the result of both left and right outer join and returns all rows (don?t care its matched or unmatched) from the both participating tables.

Syntax for full outer join:

  1. SELECT *
  2. FROM table1
  3. FULL OUTER JOIN table2
  4. ON table1.column_name = table2.column_name;

Note:here table1 and table2 are the name of the tables participating in joining and column_name is the column of the participating tables.

Let us take two tables to demonstrate full outer join:

table_A

A M
1 m
2 n
4 o

table_B

A N
2 p
3 q
5 r

Resulting table

A M A N
2 n 2 p
1 m
4 o
3 q
5 r

Because this is a full outer join so all rows (both matching and non-matching) from both tables are included in the output. Here only one row of output displays values in all columns because there is only one match between table_A and table_B.

Pictorial representation of full outer join:

PinIt
submit to reddit

Leave a Reply

Top