Lesson 11Adding JOIN Queries

Relational databases model both data and relationships within the data. Their approach to relationships is clever.

  • Related things don't have to be stored together.
  • You can ignore related data when you don't need it.
  • When you need related data, it's quick to retrieve.

Up to this point, the SELECT queries you've created ignore related data. They retrieve data from one table at a time. A single table SELECT is powerful, but it doesn't take advantage of SQL's full potential. With one small tweak, adding a bit of JOIN syntax, SELECT queries can read from multiple tables and express relationships between data explicitly.

STARTING WITH A SCHEMA

For this lesson, the TrackIt schema will be used. You can create this schema by running the trackit‐schema‐and‐data.sql script that can be found in the Lesson 11 folder on the downloadable files for this book.

The script ...

Get Job Ready SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.