In today’s article, what is JOIN in PostgreSQL? and what are JOINs used for? We will explain the questions.
Databases are not just one table. The reason for this is usually to avoid data duplication. In databases created in this way, “Table Join” is performed in order to use the values in the tables in relation to each other.
This join operation can occur in two different tables. It may also be the case for more than two tables. For this, the tables must be linked to each other with Primary Key and Foreign Keys.
When we need, we can join different tables with related data with the help of JOIN. With the JOIN statement, we can join a table with itself, or it is possible to join more than one table with this statement. When we perform these join operations, we can use different methods for the operations we want.
These different methods are carried out by means of different commands within themselves with the JOIN statement. Therefore, JOIN statements are very important in database programming.
The following picture shows the types of joins and the areas they affect.
In the picture above, the columns that will be affected in our tables and the matches to be used for these columns are indicated.
Join types are listed below.
– JOIN or INNER JOIN (both mean the same thing)
– OUTER JOIN
– LEFT JOIN or LEFT OUTER JOIN (both mean the same thing)
– RIGHT JOIN or RIGHT OUTER JOIN (both mean the same thing)
– FULL JOIN or FULL OUTER JOIN (both mean the same thing)
– CROSS JOIN
– NATURAL JOIN
Join types make it easier for us to understand how tables link together.