Left Join Usage in SQL

Itacen Sabacok | Jan 19, 2022

LEFT JOIN keyword returns all records from the left table (table 1), and the matching records from the right table (table 2). The result is 0 records from the right side, if there is no match.

NOTE

In some databases LEFT JOIN is called LEFT OUTER JOIN

Here is the sample of Engineer table

id fullname title department manager
1 Eric Brown Software Engineer IT Frank Martin
2 Brandon Hart DevOps Engineer IT Justin Martin
3 Connor Langdon Software Engineer IT Lucas Scott

Here is the sample of Certificate table

id engineerid certificatename certificatedate
1 1 Docker Certified Associate 2020-05-05
2 2 Certified Kubernetes Administrator 2021-07-03

Examples / Outputs

1SELECT e.id, e.fullname "Full Name", 
2c.certificatename "Certificate Name"
3FROM engineer AS e
4LEFT JOIN certificate as c
5ON e.Id=c.engineerid;
id Full Name Certificate Name
1 Eric Brown Docker Certified Associate
2 Brandon Hart Certified Kubernetes Administrator
3 Connor Langdon