From the course: MySQL Data Analysis
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
LEFT JOIN - MySQL Tutorial
From the course: MySQL Data Analysis
LEFT JOIN
- [Instructor] Okay, now we're going to introduce our next type of JOIN, the LEFT JOIN. LEFT JOIN returns all records from your left table, the first table you name, and any matched records from the right table. The syntax looks very similar to INNER JOIN. The only difference is you're writing LEFT JOIN instead of INNER. LEFT JOIN tells SQL to return the overlap and everything from the left table. So even if there's no match, you won't lose any data from your first table. This is where you prescribe which right table you want to join to and tell the server which columns to make the match on. Here's an example. You're selecting some data from rental and then you're Left Joining to customer on rental.customer_id=customer.customer_id. So the difference here is when we used INNER JOIN, you would only get records back when there was a match. In this case, you're going to get all of the data from the rental table, even if there isn't a match, and you'll get any matches from the customer…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Introduction30s
-
(Locked)
Normalization and Cardinality3m 47s
-
(Locked)
Relationship diagrams1m 10s
-
(Locked)
Multi-table querying1m 4s
-
(Locked)
Reviewing the maven movies database1m 44s
-
(Locked)
Common JOIN types2m 25s
-
(Locked)
INNER JOIN1m 31s
-
(Locked)
INNER JOIN example5m 49s
-
(Locked)
Challenge: INNER JOIN42s
-
(Locked)
Solution: INNER JOIN4m 13s
-
(Locked)
LEFT JOIN1m 39s
-
(Locked)
LEFT JOIN example4m 43s
-
(Locked)
Challenge: LEFT JOIN42s
-
(Locked)
Solution: LEFT JOIN3m 57s
-
(Locked)
RIGHT JOIN1m 41s
-
(Locked)
LEFT vs. INNER vs. RIGHT JOIN3m 18s
-
(Locked)
FULL OUTER JOIN1m 27s
-
(Locked)
Pro tip: Bridging unrelated tables6m 51s
-
(Locked)
Challenge: Bridging tables57s
-
(Locked)
Solution: Bridging tables4m 25s
-
(Locked)
Multi-condition joins2m 40s
-
(Locked)
Challenge: Multi-condition joins44s
-
(Locked)
Solution: Multi-condition joins4m 42s
-
(Locked)
The UNION operator2m 15s
-
(Locked)
UNION example3m 51s
-
(Locked)
Challenge: The UNION operator32s
-
(Locked)
Solution: The UNION operator2m 41s
-
(Locked)
-