Joining Data in SQL

Join two or three tables together into one, combine tables using set theory, and work with subqueries in PostgreSQL.
Start Course for Free
5 Hours13 Videos53 Exercises207,540 Learners
4400 XP

Create Your Free Account

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

Now that you've learned the basics of SQL in our <a href="">Intro to SQL for Data Science</a> course, it's time to supercharge your queries using joins and relational set theory. In this course, you'll learn all about the power of joining tables while exploring interesting features of countries and their cities throughout the world. You will master inner and outer joins, as well as self joins, semi joins, anti joins and cross joins—fundamental tools in any PostgreSQL wizard's toolbox. Never fear set theory again after learning all about unions, intersections, and except clauses through easy-to-understand diagrams and examples. Lastly, you'll be introduced to the challenging topic of subqueries. You will be able to visually grasp these ideas by using Venn diagrams and other linking illustrations.

  1. 1

    Introduction to joins

    In this chapter, you'll be introduced to the concept of joining tables, and will explore the different ways you can enrich your queries using inner joins and self joins. You'll also see how to use the case statement to split up a field into different categories.
    Play Chapter Now
  2. 2

    Outer joins and cross joins

    In this chapter, you'll come to grips with different kinds of outer joins. You'll learn how to gain further insights into your data through left joins, right joins, and full joins. In addition to outer joins, you'll also work with cross joins.
    Play Chapter Now
  3. 3

    Set theory clauses

    In this chapter, you'll learn more about set theory using Venn diagrams and get an introduction to union, union all, intersect, and except clauses. You'll finish by investigating semi joins and anti joins, which provide a nice introduction to subqueries.
    Play Chapter Now
  4. 4


    In this closing chapter, you'll learn how to use nested queries and you'll use what you’ve learned in this course to solve three challenge problems.
    Play Chapter Now
In the following tracks
Data Analyst Data Analyst SQL FundamentalsSQL Server Fundamentals
Filip SchouwenaarsColin Ricardo
Introduction to SQL
Chester Ismay Headshot

Chester Ismay

Data Science Evangelist at DataRobot
Chester leads data science, machine learning, and data engineering in-person workshops for DataRobot University with DataRobot. He built (and helped instructors build) R, Python, SQL, and Spreadsheets courses for DataCamp first as a Curriculum Lead and then as Head of Content Development. He obtained a PhD in Statistics from Arizona State University and has taught courses and led workshops in mathematics, computer science, statistics, data science, and sociology. He is co-author of the fivethirtyeight R package and author of the thesisdown R package. He is also a co-author of ModernDive, an open-source textbook for introductory statistics and data science students using R.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA