LEFT JOIN

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


Syntax:

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

Query:

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


Output
:

Left Join Example

Tester Usage Tips:

  • Validate records from more than 1 table where all records from left table are fetched and matching records from right table are fetched. For example all students information left table and matching exam results in right table , if the students has not attended the exam null is fetched.