In this instructional video, Austin Libal, a trainer at Pragmatic Works, walks viewers through one of the foundational concepts in SQL: joining tables using INNER JOIN and LEFT OUTER JOIN. These two types of joins are among the most commonly used and are essential for anyone working with relational databases.
Joins allow users to combine data from multiple tables to generate meaningful insights. For example, a Product table might contain all available products, while a Sales table lists individual transactions. To analyze product performance, these tables must be joined meaningfully.
Austin begins by explaining the INNER JOIN, which returns only the matching records from both tables involved in the join. Using a classic Venn diagram for illustration, he highlights that:
Production.Product and Sales.SalesOrderDetail tables will be shown.Next, Austin explains the LEFT OUTER JOIN, which includes all records from the left (first) table and any matching records from the right (second) table. Key takeaways include:
To bring theory into practice, Austin demonstrates SQL queries using the AdventureWorks database. Here's a breakdown of the exercise:
SELECT * FROM Production.Product and finds 504 total products.Sales.SalesOrderDetail table, which contains 121,000+ sales entries.SELECT DISTINCT ProductID FROM Sales.SalesOrderDetail, he discovers that only 266 unique products have been sold.In the next step, Austin writes an INNER JOIN using aliases to simplify syntax:
SELECT p.ProductID
FROM Production.Product AS p
JOIN Sales.SalesOrderDetail AS sod
ON p.ProductID = sod.ProductID
He points out the importance of qualifying column names (like p.ProductID) to avoid ambiguity, especially when both tables share column names.
To retrieve all products, regardless of whether they've been sold, Austin modifies the previous query:
SELECT p.ProductID
FROM Production.Product AS p
LEFT JOIN Sales.SalesOrderDetail AS sod
ON p.ProductID = sod.ProductID
ORDER BY p.ProductID
He explains that this LEFT JOIN pulls all products from the product table and includes sales data when available. Products without sales appear with NULL in the sales columns, effectively showing what hasn’t been sold.
Austin wraps up by emphasizing when to use each type of join:
This session is part of Pragmatic Works' training series on SQL. For those eager to deepen their SQL expertise, Austin recommends exploring the company’s on-demand learning library or attending a live SQL boot camp. These resources offer structured lessons designed to elevate learners from beginner to advanced levels rapidly.
Don't forget to check out the Pragmatic Works' on-demand learning platform for more insightful content and training sessions on SQL and other Microsoft applications. Be sure to subscribe to the Pragmatic Works YouTube channel to stay up-to-date on the latest tips and tricks.