Databases Reference
In-Depth Information
Figure 4-19. Using LEFT OUTER JOIN s
How It Works
Had you used an inner join you would have missed the row for the new employee. (Try it
for yourself.) The only new SQL in the FROM clause is the JOIN operator itself.
left outer join
You also add an ORDER BY clause to sort the result set by first name within last name,
to see that the kind of join has no effect on the rest of the query, and to see an alternative
way to specify columns, by position number within the SELECT list rather than by name.
This technique is convenient (and may be the only way to do it for columns that are pro-
duced by expressions, for example, by the SUM function).
order by
2, 1
Note that the OrderID column for the new employee is null, since no value exists for
it. The same holds true for any columns from the table that don't have matching rows (in
this case, the right table).
Search WWH ::




Custom Search