December 2013
Intermediate to advanced
1872 pages
153h 31m
English
An outer join is used to return all the rows from the specified outer table (specified with LEFT OUTER, RIGHT OUTER, or FULL OUTER), even if the other table has no match. Rows returned from the outer table that have no corresponding match in the inner table display the value NULL for any columns retrieved from the inner table. For example, you might want to display the IDs of all salespersons along with the their sales territory, if assigned:
SELECT sp.BusinessEntityID as SalesPersonID, st.Name AS TerritoryFROM Sales.SalesPerson spLEFT OUTER JOIN Sales.SalesTerritory stON st.TerritoryID = sp.TerritoryIDgo/* outputSalesPersonID Territory------------- ---------------- 274 NULL ...