LEFT JOIN RIGHT JOIN and FULL JOIN in SQL

For Complete YouTube Video: Click Here

This class will try to understand LEFT JOIN RIGHT JOIN and FULL JOIN in SQL.

We have already discussed the concepts of INNER JOIN in our previous class.

LEFT JOIN RIGHT JOIN and FULL JOIN in SQL

Below are the definition of LEFT JOIN RIGHT JOIN and FULL JOIN in SQL.

LEFT JOIN

LEFT JOIN is used to select all the records from LEFT Table and match records from the right table.

RIGHT JOIN

RIGHT JOIN is used to select all the records from the RIGHT table and match records from the left table.

FULL JOIN

FULL JOIN selects all the records from both the table regardless of the condition met or not.

To understand the concepts, consider the tables given below.

LEFT JOIN RIGHT JOIN and FULL JOIN in SQL
LEFT JOIN RIGHT JOIN and FULL JOIN

The following are queries applied to the above tables.

SELECT s.stunum, s.stuname, b.bname FROM studenttable s LEFT JOIN branchtable b ON s.bnum = b.bnum;

The output of the above query is below.

LEFT JOIN RIGHT JOIN and FULL JOIN in SQL 1
LEFT JOIN RIGHT JOIN and FULL JOIN 1

SELECT s.stunum, s.stuname, b.bname FROM studenttable s RIGHT JOIN branchtable b ON s.bnum = b.bnum;

The output of the above query is below.

LEFT JOIN RIGHT JOIN and FULL JOIN in SQL 2
LEFT JOIN RIGHT JOIN and FULL JOIN in SQL 2

SELECT s.stunum, s.stuname, b.bname FROM studenttable s FULL JOIN branchtable b ON s.bnum = b.bnum;

The output of the above query is below.

LEFT JOIN RIGHT JOIN and FULL JOIN in SQL 3
LEFT JOIN RIGHT JOIN and FULL JOIN in SQL 3