At the early stages, it’s confusing what left and right join is actually all about, and which to apply where and what will be the outcome for the same.
Today I will try to show with an example what the difference between left and right join actually is with practical examples.
Create two tables and we call it A and B. Both will have two fields, i.e., id and name.
- create table A(IDint, Name varchar (10))
- GO
- create table B(IDint, Name varchar (10))

We have two records in A and three records in B.
Left Join
Fetches data from the left table no matter that data is there in the right table. If data is there in the right table it will show the same, else it will show the null values.
Right Join
Fetches the data from the right table no matterthat data is there in the left table. If data is there in the left table, it will show the same, else it will show the null values.

Let us see the result of the queries:
- Query:
Output:- Select * FROM A leftJOIN B ON A.id = B.id
Description: We have two records in table 1, so left join will match the same in the table 2, and hence it found the matching records in table two.
- Query:
Output:- SELECT * FROM B RightJOIN A on B.id = A.id

Description: Here the output for both the queries is the same. In the second query we are doing right join with table A and table A is having 2 records.
- Query:
Output:- Select*from A rightjoin B on A.id = B.id

Description: In this query we are doing right join with table B which is having 3 records. So in the output it showed the record 3rd from table B. But in table A no matching records were found, so it showed null values for the same.
- Query:Output:
- select * from B LEFTjoin A on A.id = B.id

Description: In this query we are doing left join with table B which is having 3 records. So in the output it showed the record 3rd from table B. But in table A no matching records were found, so it showed null values for the same.

SubashPosted Jul 4, 2016, 8:51 AM
Simple and Good
Nishant MittalPosted Jan 24, 2016, 12:44 AM
Thanks
Santhakumar MunuswamyPosted Jan 23, 2016, 2:19 AM
Thanks for nice share
Nishant MittalPosted Jan 22, 2016, 11:34 AM
Thanks Jaco
Jaco ZwartsPosted Jan 22, 2016, 11:16 AM
Thank you so much helping me with my studies!, really good explanation
Nishant MittalPosted Jan 21, 2016, 7:04 AM
Thanks Anil
Anil Kumar MurmuPosted Jan 21, 2016, 6:58 AM
good explanation..
Nishant MittalPosted Jan 20, 2016, 11:24 PM
Thanks Guys
Raja TPosted Jan 20, 2016, 10:52 PM
Nice, Thanks for sharing
Vipul MalhotraPosted Jan 20, 2016, 5:49 AM
nice article
Nishant MittalPosted Jan 20, 2016, 5:46 AM
Thanks Bro..
Pankaj Kumar ChoudharyPosted Jan 20, 2016, 5:33 AM
Nice Explain Sir..
Nishant MittalPosted Jan 20, 2016, 5:15 AM
Thanks Guys ...
Nanddeep NachanPosted Jan 20, 2016, 5:02 AM
Nice share
Yashwant VishwakarmaPosted Jan 20, 2016, 4:23 AM
Nice work, thank for sharing
Shubham KumarPosted Jan 20, 2016, 3:47 AM
nice