Joining Tables

Dearly Beloved, we are gathered here today . . . the classic opening line for marriage ceremonies. Okay, so the marriage analogy doesn’t work so well, but bringing data together is like a marriage—you are going to join two objects together and if the relationship is...

Inner Join

An INNER JOIN is used to get rows that match in each table. In this instance we want to know which cats also live with a dog—each pet must have the other. If they don’t, they won’t show up in our results. When they have to exist in both tables, we use an INNER JOIN....

Left Outer Join

We use a LEFT OUTER JOIN when we want to see all the rows of one table and any rows that match our join criteria from the second. Each join syntax is similar, so you won’t be surprised to see the keyword LEFT OUTER JOIN is used to define the join along with the...

Right Outer Join

We use a RIGHT OUTER JOIN when we want to get all the values from the table on the right, or the ‘joined’ table, and then see the matching data from the first table, or the table on the left. The now familiar join syntax will be RIGHT OUTER JOIN followed by ON with...