• Learning MySQL By Example
  • Introduction
  • 1. How to Retrieve Data From a Single Table
  • 2. How to Retrieve Data from Multiple Tables
  • 3. Using Functions
  • 4. How to Insert, Update, Delete Data in Tables
  • 5. Summary Queries and Aggregate Functions
  • 6. Working With Subqueries
  • 7. SQL Views
  • 8. SQL Indexes
  • Glossary
  • Index
  • Download
  • Translations
  • 2.2

    Joining More Than Two Tables

    How to Join More than Two Tables

    • To include more tables in the query, you simply add more additional JOIN clauses

    Code Snippet:

    1    USE world; 
    2    SELECT ci.name AS "City Name",
    3        co.name AS "Country Name", 
    4        cl.language AS "Country Language" 
    5    FROM city ci
    6        JOIN country co 
    7            ON ci.CountryCode = co.Code 
    8        JOIN country language cl 
    9            ON cl.CountryCode = ci.CountryCode;

    Results:

    02_joins.png

    JOIN countrylanguage cl.

    ON cl.CountryCode = ci.CountryCode;

    This content is provided to you freely by EdTech Books.

    Access it online or download it at https://edtechbooks.org/learning_mysql/joining_more_than_tw.