From the course: SQL Essential Training

The INNER JOIN - SQL Tutorial

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.

Contents