Skip to content
Joining Data in SQL
  • AI Chat
  • Code
  • Report
  • 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 integrations 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.

    Inner Join: Looks for records in boht tables which match on a given field - e.g., join ID of left table, and id of right table

    SELECT prime_ministers.country, prime_ministers.continent, prime_minister, president FROM prime_minister INNER JOIN presidents ON prime_ministers.country = presidents.country ;

    Note: the table.column_name format must be used when selecting columns that exist in both tables to avoid error - Alias table names for ease

    SELECT p1.country, p1.continent, prime_minister, president FROM prime_ministers as p1 INNER JOIN presidents as p2 ON p1.country = p2.country;

    USING can offer SQL shortcut when joining to identical column names

    USING example: SELECT p1.country, p1.continent, prime_minister, president FROM prime_ministers as p1 INNER JOIN presidents as p2 USING (country);

    Left and Right Joins

    Left Joins: return all records in the left table, and those records in the right table that match on the joining field provided Syntax is is similar - LEFT JOIN variable AS alais

    SELECT p1.country, prime_minister, president FROM prome_ministers as P1 LEFT JOIN presidents as p2 USING (country) ;

    Right Joins: return all records in the right table, even when those records in the right table that don't match joining field provided in left table

    Add your notes here

    Unknown integration
    DataFrameavailable as
    world_info
    variable
    -- Add your own queries here
    SELECT *
    FROM world.languages 
    LIMIT 5
    
    
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.