Chapter 7: Selecting Data Part 3

 

We’ve covered quite a few data selection concepts in the last two chapters. Those two chapters focused mainly on selecting data from a single table.

 

In this chapter, we’ll learn to select and combine data from one or more tables.

 

Joins

 

Let’s start with joins.

 

Like the name suggests, a join is used to join data from different tables based on a related column between the tables.

 

The syntax for joining two tables is:

 

SELECT [table_names.]columns_names_or_other_information

FROM

left_table

JOIN / INNER JOIN / LEFT JOIN / RIGHT JOIN

right_table

ON

left_table.column_name = right_table.column_name;

 

There are three main types of joins in mySQL: inner join, left join and right join. These are represented ...

Get Learn SQL using MySQL in One Day and Learn It Well now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.