SQL JOINS

JOIN is used to query data from 2 or more tables.

These tables are related to each other somehow, through some of its columns.

There are 4 types of joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN.

A primary key is a column with a unique value for each record in a table.

The purpose of JOIN is to join data from different tables, to avoid having to repeat information in different tables.

example:

If we have the following tables:

Table "people" with primary key "per"

pernamesurnamenicknamedep
1HARRYCLARKWHITE1
2HARRYSMITHJOHNSON2
3JOHNBROWNANDERSON2

table "departments" with primary key "dep"

depdepartment
1ADMINISTRATION
2COMPUTER
3BUSINESS

If we know the names of the people who work in COMPUTER, would have to do a join between 2 tables "people" and "departments" that would relate to the column "dep."

This means that from the table "people" and by the column "dep", we can access the information in the table "departments."