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:

  SELECT *  

FROM table1  

FULL OUTER JOIN table2  

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

    AM
    1m
    2n
    4o

    table_B

    AN
    2p
    3q
    5r

    Resulting table

    AMAN
    2n2p
    1m
    4o
    3q
    5r

    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:


    Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *