Left Join v/s Right Join
Parameter |
Left Join |
Right Join |
---|---|---|
Definition |
Left Join retrieves all the records and the data from the left table and all matching records from the right table. |
Right Join retrieves all the records and the data from the right table and all matching records from the left table. |
Join Keyword Use |
Here, the “LEFT JOIN” keyword is used. |
Here, the “RIGHT JOIN” keyword is used. |
Table Precedence |
In Left Join, the left table is given higher precedence. |
In Right Join, the right table is given higher precedence. |
Matching Rows |
In Left Join it returns rows from both tables and all the rows from the left table. |
In Right Join it returns rows from both tables and all rows from the right table. |
Usage |
Left Join is more used as compared to Right Join. |
Right Join is less used as compared to Left Join. |
Syntax |
SELECT columns |
SELECT columns FROM left_table RIGHT JOIN right_table ON join_condition; |
Difference Between Left Join and Right Join
Database management system or DBMS is the application software that allows us with its feature to store and manage the data which is collected from different types of sources. Now these sources can be from social media, user feedback, real-time generated data, etc.
Database Management System follows the standardized model, which is a relational model and it uses the SQL language which is a Structured Query Language through which the programmers or developers can write the custom query and retrieve or store the data in the database in the form of tables. There can be some scenarios where we need to return the result by combining the two tables.
So for that purpose, joins come into the picture. Joins in the database are used to combine two tables. So in this article, we will go through the detailed information about two types of important joins in DBMS, that is Left Join and Right Join.