SQL -Structured Query Language - SQL Joins - Left Join Tutorial
Left Join or Left Outer Join is used to retrieve all the records from the left table ( table which is mentioned first – table1) and the records that are matched from the right table( table which is mentioned second – table2).
We can perform left joins in multiple tables.
The syntax for left joins is-
table_1 LEFT JOIN table_2
table_1.column_name = table_2.column_name;
employees.employee_id = job_history.employee_id;
Better to use AS (Alias) for the long table name-
employees as e
job_history as jh
e.employee_id = jh.employee_id;
Here we will get all records from the left table (employees) and only those records where id will get matched in both employees and job_history table.
Another record that is not matched in the right table (table2) will not get retrieved.
Best learning portal that provides you great learning experience of various technologies with modern compilation tools and technique
Don't hesitate to give us a call or send us a contact form message