Why JOINs combine related tables
📖 Scenario: You work at a small bookstore. The store keeps two tables: one for books and one for authors. Each book has an author ID that matches an author in the authors table. You want to see the book titles along with their authors' names.
🎯 Goal: Build a simple SQL query using a JOIN to combine the books and authors tables so you can see each book's title with the correct author's name.
📋 What You'll Learn
Create a table called
authors with columns author_id (integer) and author_name (text).Create a table called
books with columns book_id (integer), title (text), and author_id (integer).Insert exactly these authors into
authors: (1, 'Jane Austen'), (2, 'Mark Twain').Insert exactly these books into
books: (101, 'Pride and Prejudice', 1), (102, 'Adventures of Huckleberry Finn', 2).Write a SQL
SELECT query using JOIN to combine books and authors on author_id.Select the
title from books and the author_name from authors.💡 Why This Matters
🌍 Real World
Combining related tables is common in real databases to get meaningful information from separate data sources, like matching books to their authors.
💼 Career
Understanding JOINs is essential for database jobs, data analysis, and backend development where data from multiple tables must be combined.
Progress0 / 4 steps