• iconteach@devfunda.com

Understanding Joins

Understanding Joins

07-09-2025 16:39:07 Time to read : 12 Minutes

In databases, information is often spread across multiple tables.
For example, students are stored in one table, and their departments are in another. 

A JOIN is a means for combining fields from two tables by using values common to each.

To combine related data from different tables, we use JOINs.

Different types of JOINs allow us to combine data from multiple tables, making it possible to perform complex queries and handle relationships between tables more effectively.

Types of Joins in PostgreSQL

  • INNER JOIN: Returns only the rows that have matching values in both tables.
  • LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table, and matching rows from the right table (null if no match).
  • RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table, and matching rows from the left table (null if no match).
  • FULL JOIN (or FULL OUTER JOIN): Returns all rows from both tables, with nulls where there is no match.
  • CROSS JOIN: Returns the cartesian product (every row in table A combined with every row in table B).

 

Want to learn in class