Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Data
Labs

SQL Fundamentals: Techniques for Joining Tables

In this lab, you will learn essential SQL techniques for working with multiple tables in a database. You will practice using INNER JOIN, LEFT JOIN, RIGHT JOIN, and UNION to retrieve and combine data from different tables. Additionally, you'll explore how to retrieve distinct values and handle missing data effectively. By the end of the lab, you will have a solid understanding of how to query complex datasets using various join operations and filtering techniques.

Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 23, 2025
Duration
50m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Inner Joins

    SQL Guide

    For each task, replace or update the existing SQL code in the top pane (main.sql) with your answer to the task and run it to see the results in the bottom pane (SQL Viewer).


    Step 1: Inner Joins

    To review the concepts covered in this step, please refer to the course Summarizing Data with GROUP BY module of the Introduction to SQL Course.

    In this step, you will learn how to use the INNER JOIN clause to combine data from two or more tables. An INNER JOIN retrieves only the rows where there is a match between the tables involved. You will practice combining tables such as Employee and Department to retrieve employee and department information, as well as other related tables. This step will help you gain a solid understanding of how to join tables using matching columns.

    Database Schema

    Employee

    | Column | Data Type | |--------------|-------------------| | EmployeeID | INT | | FirstName | VARCHAR(100) | | LastName | VARCHAR(100) | | Salary | DECIMAL(10, 2) | | DepartmentID | INT |

    Department

    | Column | Data Type | |----------------|------------------| | DepartmentID | INT | | DepartmentName | VARCHAR(100) |

    Customer

    | Column | Data Type | |---------------|-------------------| | CustomerID | INT | | CustomerName | VARCHAR(100) |

    Orders

    | Column | Data Type | |---------------|-------------------| | OrderID | INT | | CustomerID | INT | | OrderDate | DATE |

    Product

    | Column | Data Type | |---------------|-------------------| | ProductID | INT | | ProductName | VARCHAR(255) | | Category | VARCHAR(100) | | ListPrice | DECIMAL(10, 2) |

    Review

    | Column | Data Type | |---------------|-------------------| | ReviewID | INT | | ProductID | INT | | ReviewText | TEXT |

  2. Challenge

    Outer Joins

    Step 2: Outer Joins

    In this step, you will explore LEFT JOIN and RIGHT JOIN operations, which retrieve all records from one table, along with the matched records from the second table. If there is no match, NULL values will be displayed for columns from the other table. You will work with tables such as Employee and Department to retrieve all employees (even those without a department) or all departments (even those without employees). By the end of this step, you will understand how to handle incomplete data using outer joins.

    Database Schema

    Employee

    | Column | Data Type | |--------------|-------------------| | EmployeeID | INT | | FirstName | VARCHAR(100) | | LastName | VARCHAR(100) | | Salary | DECIMAL(10, 2) | | DepartmentID | INT |

    Department

    | Column | Data Type | |----------------|------------------| | DepartmentID | INT | | DepartmentName | VARCHAR(100) |

    Customer

    | Column | Data Type | |---------------|-------------------| | CustomerID | INT | | CustomerName | VARCHAR(100) |

    Order

    | Column | Data Type | |---------------|-------------------| | OrderID | INT | | CustomerID | INT | | OrderDate | DATE |

  3. Challenge

    Natural Joins

    Step 3: Natural Joins

    In this step, you will learn how to use the NATURAL JOIN to join tables based on columns that share the same name and data type in both tables. A NATURAL JOIN automatically infers the join condition, simplifying queries when working with databases that have consistent naming conventions. You will practice using this technique with tables like Product and Review to join them on their common columns. This approach is useful when tables are designed with matching column names, allowing for simpler join conditions.

    Database Schema

    Product

    | Column | Data Type | |---------------|-------------------| | ProductID | INT | | ProductName | VARCHAR(255) | | Category | VARCHAR(100) | | ListPrice | DECIMAL(10, 2) |

    Review

    | Column | Data Type | |---------------|-------------------| | ReviewID | INT | | ProductID | INT | | ReviewText | TEXT |

    Customer

    | Column | Data Type | |---------------|-------------------| | CustomerID | INT | | CustomerName | VARCHAR(100) |

    Order

    | Column | Data Type | |---------------|-------------------| | OrderID | INT | | CustomerID | INT | | OrderDate | DATE |

About the author

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight