RIGHT JOIN

The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match.


Syntax:

SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;

Query:

SELECT employees.emp_no, employees.last_name, employees.first_name, salaries.salary 
FROM `employees` RIGHT JOIN salaries ON employees.emp_no=salaries.emp_no

Output:

Right Join Example

Tester Usage Tips:

  • Validate records from more than 1 table where all records from right table are fetched for example student accounts info with student personal demographics details that is all right accounts details records are fetched and only available student demographics or null is fetched