Introduction
In the previous chapter, we saw how the WHERE
clause can be used to filter elements and provide us with more control over the data we can retrieve from a table. However, in many cases, not all the data we require can be found in a single table. Having a single table to store all the data is also not feasible because its maintenance will be extremely difficult. One way of connecting tables and retrieving data from them is by using joins.
We can use the JOIN
operation to extract data from multiple tables that have common columns using a single query. Based on the data that's required, there are various types of joins that are supported by SQL.
In this chapter, we will look at the following types of joins that are available in SQL:
INNER JOIN
RIGHT JOIN
LEFT JOIN
CROSS JOIN
UNION
Each topic in this chapter will illustrate a type of JOIN
. We will be working with the PACKT_ONLINE_SHOP
throughout this chapter. First, we'll begin...