Exploring INNER JOIN
Introduction
Welcome back! In the previous lesson, we covered different types of SQL JOINs, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN, using the Marvel movies dataset. Today, we're going to dive deeper into INNER JOIN and learn how to link the movies table with the movie_details and characters table. This lesson will help you understand how to combine data from these tables effectively.
Dataset Refresher
To give you a quick reminder, here are the three tables we are using:
Movies Table
| movie_id | movie_name |
|---|---|
| 1 | Iron Man |
| 2 | The Incredible Hulk |
| 3 | Captain America: The First Avenger |
| 4 | The Avengers |
Movie Details Table
| movie_id | imdb_rating | box_office_million_usd |
|---|---|---|
| 1 | 7.9 | 585.2 |
| 3 | 6.9 | 370.6 |
| 4 | 8.0 | 1519.6 |
Characters Table
| character_id | movie_id | character_name |
|---|---|---|
| 1 | 1 | Tony Stark/Iron Man |
| 2 | 1 | Pepper Potts |
| 3 | 1 | James Rhodes |
| 4 | 1 | Obadiah Stane |
| 5 | 3 | Steve Rogers/Captain America |
| 6 | 3 | Peggy Carter |
| 7 | 3 | Bucky Barnes/Winter Soldier |
| 8 | 3 | Johann Schmidt/Red Skull |
| 9 | 3 | Howard Stark |
| 10 | 4 | Steve Rogers/Captain America |
| 11 | 4 | Tony Stark/Iron Man |
| 12 | 4 | Thor |
| 13 | 4 | Natasha Romanoff/Black Widow |
| 14 | 4 | Bruce Banner/Hulk |
| 15 | 4 | Clint Barton/Hawkeye |
| 16 | 4 | Loki |
| 17 | 5 | T'challa |
The common key linking all these tables is movie_id.
