Joining Tables


Sometimes you just query a single table to retrieve data. But often you are dealing with two or more tables. To connect them, you need to use joins. There are four types of joins:
1.      Inner join
2.      Left outer join
3.      Right outer join
4.      Cross join

The inner join is the default join. Only matches from the left and right side of the join will be produced. The left outer join, or left join, will give you all rows from the left-hand side. It will also include matches from the right-hand side. Similarly, the right outer join gives you all rows from the right-hand side. It will also include matches from the left-hand side.
The cross join produces something known as a Cartesian product. Every row from the left side is matched with every row from the right side. If there are m rows on the left, and n rows on the right, the cross join will result in m x n rows.