The place where the Information Matters

SQL JOINS – Explanation with Examples

0

SQL Joins are one of the most used functionalities while writing the SQL Queries. They are the clause used to combine rows from two or more tables based on the common/related column between the participating tables. Various joins are used in the SQL Query.

Types of Join

  1. INNER JOIN

Inner Join is the Default join in the Query. It retrieves the Common records from the Joining Tables.

2. OUTER JOIN

A. LEFT OUTER JOIN

Retrieves data Matching data from Joining Tables as well as remaining data from the Left Table.

B. RIGHT OUTER JOIN

Retrieves data Matching data from Joining Tables as well as remaining data from the Right Table.

  1. FULL JOIN

This join retrieves all the data from both Left and Right Tables.

To Make it easier Let’s take a pictorial example

Join

In this Example,

Inner Join will give: 4, 5

Left Outer Join will give: 1, 2, 3, 4, 5

Right Outer Join will give: 4, 5, 6, 7, 8

Full Outer Join/Full Join will give: 1, 2, 3, 4, 5, 6, 7, 8

 

Summary of Joins

 

Joins

 

To make it more clear

Using Tables to explain the joins          

INNER JOIN

 

 Joins

LEFT OUTER JOIN

Joins

RIGHT OUTER JOIN

 

Joins

FULL OUTER JOIN

 

Joins

     I Hope it was helpful.     

          

The article was collected and written by Bijaya Subedi. Bijaya is currently working as an ETL tester in a DC/VA based Mortgage Company.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.