From the course: SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Solution: Join tables - SQL Tutorial
From the course: SQL: Data Reporting and Analysis
Solution: Join tables
(upbeat music) - [Instructor] We can start by joining just two tables together. This could be film and film_category or film_category and category because there isn't a shared field directly between the film and category tables. So whichever way you do it is fine but I'm going to join SELECT * FROM film f JOIN film_category ON film_category fc. I'll give them aliases to make life easier later on. F.film_id equals fc. So we're telling the database how to knit together the records that we're finding. Now, notice here that there are 1,000 rows returned. And notice also that we have this message up here, which doesn't grab the attention 'cause it's not in red. But it does become very significant later. The current selection does not contain a unique column. So we've got two film_id columns returned, for example. And they are not prefaced in the results table with f and fc. So the database knows that it might get…
Contents
-
-
-
-
-
-
(Locked)
Make your queries faster1m 47s
-
(Locked)
Understand SQL indexes and keys7m 16s
-
(Locked)
EDIT: Visualize your database7m 58s
-
(Locked)
Merge data across tables with JOIN5m 2s
-
(Locked)
Understand SQL JOINS4m 16s
-
(Locked)
Combine rows with SQL UNION4m 49s
-
(Locked)
Merge data across tables with IN2m 11s
-
(Locked)
Select from a selection with subqueries2m 56s
-
(Locked)
Challenge: Join tables1m 4s
-
(Locked)
Solution: Join tables4m 37s
-
(Locked)
-
-