Inner Join Vs. Outer Join: What Are The Main Differences?

When working in SQL, a join is used to combine and return specific rows of data from two or more tables within a database. There are two types of joins: inner join and outer join. An inner join will find and return matching data in tables. An outer join will find and return matching data and will return dissimilar data from tables.

 

Inner Join

 

The inner join will focus only on the commonality between two or more tables. To use an inner join, there must be at least one field of matching data within two or more tables that can be compared.

The inner join will search through the tables for any matching or overlapping data; it will then combine the data and return it in one new table. Know the difference between table and charts.

 

Outer Join

The outer join will return a set of records that will include the same data that an inner join would return. It also will return other rows of data where that is no match found in the other table or tables.

There are three types of outer joins:

  • Full outer join, also known as a full join, is not supported by MySQL. It will combine and return all data from two or more tables, no matter if there is shared information or not.
  • Right outer join, also called a right join, will return all the data from the first table and only the shared data from the other tables.
  • Left outer join, also called a left join, will return all the data from the first table and all shared data from the second table.

 

Recommended for You:

 

Inner Join Vs. Outer Join: A Comparison Table

Inner Join

Outer Join

  • Will return only shared data within two or more tables.
  • Will return shared data along with additional non-related data.
  • Only 1 type of inner join.
  • 3 types of outer joins: full, left and right.
  • Creates a new table with shared information.
  • Will return null values in report form.

 

Similar Posts