Join | What’s The Difference Between INNER JOIN, LEFT JOIN, RIGHT JOIN And FULL JOIN?

Here we will learn What’s The Difference Between INNER JOIN, LEFT JOIN, RIGHT JOIN, And FULL JOIN? where joins are used for getting the data filtered and the selected data need to display with some conditions we will learn different conditions which are applied for each type of join present there.

It is a way to get the data from two different tables in relational database management systems with some conditions instead of getting the whole data.

Join

Different types of Joins

There are four types of join SQL Inner join, Full Join, Left Join, and Right join let’s discuss them all one by one.

Inner Join

Inner join is a join where we get the common data from both tables where the rows or records which are common in both tables will be selected and all of them will be displayed.

If we talk about the ben diagram it is nothing but intersection of two given tables where the record where the primary key has the same value in both the tables in the above example three records will be the same so the output will be containing three records which have same primary key value.

It might result in to zero outcomes as there is the possibility that non of the record matches in both tables.

To implement follow the example given

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

Full Join

It is also a type of join that results in all the records of both tables which means it will not filter any record it will simply display all the records of both tables.

To get a clear idea follow the example.

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders FULL JOIN Customers ON Orders.CustomerID=Customers.CustomerID

Left Join

It will display all the records of the left table and irrespective of what position the table at the right is in common both purely focus on the left side and display all the records of it. For example, follow the code given below.

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID

Right Join

Just like the left join right join also deal with a single table but this time the table will be on the right side. So we can draw a conclusion that how we can see that it only focuses on the table only at the right side.

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID

 

To learn more about Joins visit Joins in SQL

And also visit MySQL Problems And Tutorials to learn more about different programming languages.

 

 

 

 

Leave a Comment

%d bloggers like this: