...

/

Types of Joins

Types of Joins

This lesson discusses the different types of joins as specified by ANSI SQL.

Types of Joins

In the previous section we worked with a single table to learn the basics of SQL. However, relational databases define relationships between tables and often queries require gleaning information from two or more tables. Joins allow us to combine rows from multiple tables using columns common between them. In fact, the relations defined amongst tables is what makes relational databases, relational.

To drive the concepts home, we’ll work with two tables that have one column common between them. The two tables are shown below:

Movie Table

MovieID MovieName
1 Star Wars
2 Sholay
3 The Italian Job

Cinema Table

MovieID CinemaName RunForDays
2 Naz Cinema 101
5 Apollo Theater 45

The ANSI SQL standard defines five types of joins that we’ll discuss.

Cross Join

We’ll start with the cross join, which is also known as the cartesian product. In this ...