SQL Server - RIGHT JOIN
What is RIGHT JOIN (RIGHT OUTER JOIN) in SQL Server ?
Right join is also called as Right Outer Join.
In Right Join SQL Server shows all data from right side table and common matching data from left side table. If matching record not found from left side table then SQL server show NULL value.
Below image will give you brief idea regarding right join. We have to tables and it is showing all data from right side table and matching data from left side table.
Syntax of Right Join
Note : We use the RIGHT JOIN keyword to join two or more table and ON keyword is use to add condition. We can add multiple condition using AND keyword.
Consider below two result set of tblStudentDetails table and tblStudentMarks table, having student and student marks details.
Get list of all student with there respective marks.
Note : It return all data from right side table and matching data from left side table.
tblStudentDetails called left table because it is available to left side of 'RIGHT JOIN' keyword and same for tblStudentMarks called as right table because it is available to right side 'RIGHT JOIN' keyword.
RIGHT JOIN with where condition.
Consider the below result set and select student whose marks greater than 50 and subject in Math and Science .