Top Menu

Search This Blog

SQL RIGHT JOIN

The RIGHT JOIN returns all record from the right table (table_2), with the matching record in the left table (table_1). The result is NULL in the left side when there is no match.




Syntax:

SELECT *
FROM table_1
RIGHT OUTER JOIN table_2
ON table_1.column_some_name=table_2.column_some_name

OR

SELECT *
FROM table_1
RIGHT JOIN table_2
ON table_1.column_some_name=table_2.column_some_name

As you see,In this tutorial we have two tables like this table(1) "Employee" and table(2)  "Departments".

Table 1(Employee):















Table 2(Departments):  
















Example:

 SELECT * FROM Employee e1 RIGHT OUTER JOIN Departments e2
 ON e1.DepartID = e2.id

Output:


Post a Comment

Designed by OddThemes | Distributed By Gooyaabi Templates