Skip to content
Joining Data in SQL
Joining Data with SQL
Here you can access every table used in the course. To access each table, you will need to specify the world schema in your queries (e.g., world.countries for the countries table, and world.languages for the languages table).
Note: When using sample databases such as those that contain course data, you have read-only access. You can run queries, but cannot make any changes such as adding, deleting, or modifying the data (e.g., creating tables, views, etc.).
Take Notes
Add notes about the concepts you've learned and SQL cells with queries you want to keep.
Add your notes here
DataFrameas
world_info
variable
-- Add your own queries here
SELECT *
FROM world.languages
LIMIT 100INS AND OUTS OF INNER JOIN
INNER JOIN ON
KEYWORDS -SELECT -FROM -INNER JOIN -ON USING
DataFrameas
df
variable
SELECT *
FROM world.cities;
SELECT *
FROM world.cities
INNER JOIN world.countries
ON world.cities.country_code = world.countries.code;
SELECT world.cities.name AS city, world.countries.name AS country, region
FROM world.cities
INNER JOIN world.countries
ON world.cities.country_code = world.countries.code;
SELECT c.code AS country_code, world.cities.name, e.year, e.inflation_rate
FROM world.countries AS c
INNER JOIN world.economies AS e
ON c.code = e.code
INNER JOIN world.cities
ON c.code = world.cities.country_code;
SELECT c.name AS country, l.name AS language, official
FROM world.countries AS c
INNER JOIN world.languages AS l
USING (code);
SELECT c.name AS country, l.name AS language
FROM world.countries AS c
INNER JOIN world.languages AS l
USING (code);
SELECT l.name AS language, c.name AS country
FROM world.countries AS c
INNER JOIN world.languages AS l
USING (code)
ORDER BY language;
SELECT c.name, p.year, p.fertility_rate
FROM world.countries AS c
INNER JOIN world.populations AS p
ON c.code = p.country_code;
SELECT name,e.year,fertility_rate,e.unemployment_rate
FROM world.countries AS c
INNER JOIN world.populations AS p
ON c.code = p.country_code
INNER JOIN world.economies AS e
ON c.code = e.code;
SELECT name, e.year, fertility_rate, unemployment_rate
FROM world.countries AS c
INNER JOIN world.populations AS p
ON c.code = p.country_code
INNER JOIN world.economies AS e
ON (c.code = e.code) AND (e.year = p.year);
*The ins and outs of INNER JOIN
- The two types of Join; INNER JOIN AND LEFT JOIN.