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.
Why Joins Matter
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.
The INNER JOIN
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:
- Only records present in both tables are included in the result set.
- For example, only products that appear in both the
Production.ProductandSales.SalesOrderDetailtables will be shown. - This type of join is best for finding intersecting data — such as all sold products.
The LEFT OUTER JOIN
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:
- All records from the left table are included, even if there are no matches in the right table.
- This is useful for identifying entries in the left table that lack corresponding entries in the right one — for example, products that haven't been sold.
- Null values will appear in columns from the right table when there’s no match.
Demonstration with AdventureWorks Database
To bring theory into practice, Austin demonstrates SQL queries using the AdventureWorks database. Here's a breakdown of the exercise:
- He starts by running
SELECT * FROM Production.Productand finds 504 total products. - Next, he inspects the
Sales.SalesOrderDetailtable, which contains 121,000+ sales entries. - By running
SELECT DISTINCT ProductID FROM Sales.SalesOrderDetail, he discovers that only 266 unique products have been sold. - This leaves approximately 238 products that have not been sold — highlighting the need for a LEFT OUTER JOIN.
Writing the INNER JOIN
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.
Writing the LEFT OUTER JOIN
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.
Use Cases for INNER vs. LEFT OUTER JOIN
Austin wraps up by emphasizing when to use each type of join:
- Use INNER JOIN when you're interested only in records that have a match in both tables (e.g., products that were sold).
- Use LEFT OUTER JOIN when you want to include all records from the first table, regardless of whether there's a match in the second (e.g., identifying unsold products).
Learn More with Pragmatic Works
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.
Sign-up now and get instant access
ABOUT THE AUTHOR
Austin is a Jacksonville native who graduated from The Baptist College of Florida in 2012. He previously worked as a manager in the retail service industry. He enjoys spending time with his wife and two kids. His primary focus at Pragmatic Works is on Azure Synapse Analytics and teaching the best practices for data integration, enterprise data warehousing, and big data analytics. He also enjoys helping customers learn the ins and outs of Power BI and showing people new ways to grow their business with the Power Platform.
Free Community Plan
On-demand learning
Most Recent
private training

Leave a comment