Get Started

Chaining FULL JOINs

As you have seen in the previous chapter on INNER JOIN, it is possible to chain joins in SQL, such as when looking to connect data from more than two tables.

Suppose you are doing some research on Melanesia and Micronesia, and are interested in pulling information about languages and currencies into the data we see for these regions in the countries table. Since languages and currencies exist in separate tables, this will require two consecutive full joins involving the countries, languages and currencies tables.

This is a part of the course

“Joining Data in SQL”

View Course

Exercise instructions

  • Complete the FULL JOIN with countries as c1 on the left and languages as l on the right, using code to perform this join.
  • Next, chain this join with another FULL JOIN, placing currencies on the right, joining on code again.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT 
	c1.name AS country, 
    region, 
    l.name AS language,
	basic_unit, 
    frac_unit
FROM countries as c1 
-- Full join with languages (alias as l)
___ 
-- Full join with currencies (alias as c2)
___ 
WHERE region LIKE 'M%esia';

This exercise is part of the course

Joining Data in SQL

BeginnerSkill Level
4.4+
275 reviews

Level up your SQL knowledge and learn to join tables together, apply relational set theory, and work with subqueries.

After familiarizing yourself with inner joins, you will come to grips with different kinds of outer joins. Next, you will learn about cross joins. Finally, you will learn about situations in which you might join a table with itself.

Exercise 1: LEFT and RIGHT JOINsExercise 2: Remembering what is LEFTExercise 3: This is a LEFT JOIN, right?Exercise 4: Building on your LEFT JOINExercise 5: Is this RIGHT?Exercise 6: FULL JOINsExercise 7: Comparing joinsExercise 8: Chaining FULL JOINs
Exercise 9: Crossing into CROSS JOINExercise 10: Histories and languagesExercise 11: Choosing your joinExercise 12: Self joinsExercise 13: Comparing a country to itselfExercise 14: All joins on deck

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free