Page 122 - SQL
P. 122
Departments.Name Employees.FName
HR James
HR John
HR Johnathon
Sales Michael
Tech NULL
So how does this work?
There are two tables in the FROM clause:
Id FName LName PhoneNumber ManagerId DepartmentId Salary HireDate
01-01-
1 James Smith 1234567890 NULL 1 1000
2002
23-03-
2 John Johnson 2468101214 1 1 400
2005
12-05-
3 Michael Williams 1357911131 1 2 600
2009
24-07-
4 Johnathon Smith 1212121212 2 1 500
2016
and
Id Name
1 HR
2 Sales
3 Tech
First a Cartesian product is created from the two tables giving an intermediate table.
The records that meet the join criteria (Departments.Id = Employees.DepartmentId) are
highlighted in bold; these are passed to the next stage of the query.
As this is a LEFT OUTER JOIN all records are returned from the LEFT side of the join
(Departments), while any records on the RIGHT side are given a NULL marker if they do not
match the join criteria. In the table below this will return Tech with NULL
https://riptutorial.com/ 104

