What is the difference between “INNER JOIN” and “OUTER JOIN”?

Technology CommunityCategory: SQLWhat is the difference between “INNER JOIN” and “OUTER JOIN”?
VietMX Staff asked 3 years ago
Problem

Also how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in?

Assuming you’re joining on columns with no duplicates, which is a very common case:

  • An inner join of A and B gives the result of A intersect B, i.e. the inner part of a Venn diagram intersection.
  • An outer join of A and B gives the results of A union B, i.e. the outer parts of a Venn diagram union.
  • left outer join will give all rows in A, plus any common rows in B.
  • right outer join will give all rows in B, plus any common rows in A.
  • full outer join will give you the union of A and B, i.e. all the rows in A and all the rows in B. If something in A doesn’t have a corresponding datum in B, then the B portion is null, and vice versa.