From the course: SQL Essential Training
The INNER JOIN
- [Narrator] So let's talk about the inner join. An inner join only returns matching records. Any unmatched data from either table is ignored. Joins are often described with the use of Venn diagrams. As our Venn diagram shows, an inner join represents only the overlapping section of the Venn diagram. Now, if we take a look at our simplified invoice and customer tables, we can see that our inner join will ignore invoice number five. And that is because this invoice refers to customer six, and this customer does not appear in our customer table. Likewise, customer one and customer five from the customer table did not generate any invoices. In other words, they do not have any records in the invoice table. So that record is ignored as well. As the Venn diagram shows, only the overlapping data is included. Now, if we revisit the code that we generated to produce this inner join, we can see that this is the exact SQL statement that we created when we first visited our inner join. Now, if we take a look at the output of this query, we can see that only four records were returned. Invoice number five, customer number one, and customer number five are all omitted. Customer number two is responsible for two records. Now, the inner join is the most common type of join that's used, and the main use of the inner join is to bring corresponding data together from different tables in a relational database. Now, let's move on to another join type called the left outer join.
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
-
-
-
-
-
-
-
- Joins explained1m 41s
- How tables share a relationship, part 15m 53s
- How tables share a relationship, part 24m 22s
- Simplifying JOINs5m 41s
- Types of JOINs2m 55s
- The INNER JOIN2m 20s
- The LEFT JOIN2m 59s
- The RIGHT JOIN3m 29s
- Tables and Entity Relationship diagrams4m 41s
- Joining many tables5m 45s
- Solution: Analyzing customer support interactions3m 3s
-
-
-
-
-
-
-
-