LEFT JOIN IN ORACLE SQL
A LEFT JOIN in Oracle SQL is used to combine two tables where all the records from the left table are included, and only the matching records from the right table are included. If there is no match in the right table, then the result will display NULL values for the columns from the right table.
SELECT *
FROM table1
LEFT JOIN table2
ON table1.column = table2.column;
Here's an example that demonstrates how to use a LEFT JOIN in Oracle SQL:
Assume we have two tables, "employees" and "departments", with the following data:
Table: Employees
Table: departments
To get a list of all employees and their departments, we can use a LEFT JOIN as follows:
SELECT emp_name, department_name
FROM employees
LEFT JOIN departments
ON employees.department_id = departments.department_id;
output
Notice that all the "employees" table records are included, even if there is no match in the "departments" table. For example, Sarah is included in the result, even though she has no matching department record. In this case, the department_name column displays NULL.
Tags:
ORACLE SQL