---
description: In this PostgreSQL Joins tutorial, we will learn What are PostgreSQL Joins, Types of PostgreSQL Joins like Inner, Outer, Left, &amp; Right with Example.
title: "PostgreSQL Join Types: Inner, Outer, Left, Right"
image: https://www.guru99.com/images/postgresql-join-types.png
---

[Skip to content](#main)

**⚡ Smart Summary**

PostgreSQL Joins retrieve and combine rows from two or more tables using a shared key, and include inner joins such as theta, EQUI, and natural, plus outer joins covering left, right, and full results.

- 🔗 **Combine:** Joins merge columns from multiple tables based on a common key.
- 🎯 **Inner Join:** Inner joins return only rows where the join condition is satisfied.
- ⬅️ **Left Join:** LEFT OUTER JOIN keeps every left-table row, adding NULLs for unmatched right rows.
- ➡️ **Right Join:** RIGHT OUTER JOIN keeps every right-table row, adding NULLs for unmatched left rows.
- 🔵 **Full Join:** FULL OUTER JOIN returns all rows from both tables with NULLs where no match exists.
- 🤖 **AI Help:** AI assistants pick the correct join type and write the ON condition.

Read More

![PostgreSQL Join Types](https://www.guru99.com/images/postgresql-join-types.png)

## What are Joins in PostgreSQL?

**PostgreSQL Joins** are used for retrieving data from more than one table. With Joins, it is possible for us to combine the SELECT and JOIN statements into a single statement. A JOIN condition is added to the statement, and all rows that meet the conditions are returned. The values from different tables are combined based on common columns. The common column is mostly a primary key in the first table and a foreign key of the second table.

## PostgreSQL Join Types

There are two types of Joins in [PostgreSQL](https://www.guru99.com/postgresql-tutorial.html):

- Inner Joins
- Outer Joins

## PostgreSQL Inner Join

There are 3 types of Inner Joins in PostgreSQL:

- Theta join
- Natural join
- EQUI join

### Theta Join

A theta join allows one to join two tables based on the condition that is represented by theta. Theta joins can work with all comparison operators. In most cases, the theta join is referred to as inner join.

The theta join is the most basic type of JOIN. It will return all rows from the tables where the JOIN condition is satisfied.

**Syntax:**

```
SELECT columns
FROM table-1
INNER JOIN table-2
ON table-1.column = table-2.column;
```

Consider the following tables of the Demo database:

**Book:**

[![PostgreSQL Theta Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ1.png)

**Price:**

[![PostgreSQL Theta Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ2.png)

We want to see the name of each book and the corresponding Price. We can run the following command:

```
SELECT Book.name, Price.price
FROM Book
INNER JOIN Price
ON Book.id = Price.id;
```

This will return the following:

[![PostgreSQL Theta Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ3.png)

Only 3 rows satisfied the join condition.

### EQUI Join

The EQUI join provides us with a way of joining two tables based on primary key/foreign key relationship. For example:

```
SELECT *
FROM Book
JOIN Price ON Book.id = Price.id;
```

This will return the following:

[![PostgreSQL EQUI Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ4.png)

Records have been returned from both tables based on the common columns, that is, the id column.

### Natural Join

This type of join provides us with another way of writing an EQUI join. We can improve our previous example by adding the NATURAL keyword as shown below:

```
SELECT *
FROM Book
NATURAL JOIN Price;
```

This will return the following:

[![PostgreSQL Natural Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ5.png)

Only one id column has been returned. The NATURAL JOIN was able to note that the id column is common in the two tables. Only one was returned.

**Don't Miss:**

- [PostgreSQL Tutorial for Beginners](https://www.guru99.com/postgresql-tutorial.html)
- [PostgreSQL Union, Union ALL with Examples](https://www.guru99.com/postgresql-union-example.html)
- [PostgreSQL EXISTS with SELECT Operator (Example)](https://www.guru99.com/postgresql-exists.html)
- [PostgreSQL INSERT: Inserting Data into a Table](https://www.guru99.com/postgresql-insert.html)

## PostgreSQL Outer Join

There are 3 types of Outer Joins in PostgreSQL:

- Left Outer Join
- Right Outer Join
- Full Outer Join

### PostgreSQL Left Outer Join

The LEFT OUTER JOIN will return all rows in the table on the left-hand side and only the rows in the right-hand side table where the join condition has been satisfied.

**Syntax:**

```
SELECT columns
FROM table-1
LEFT OUTER JOIN table-2
ON table-1.column = table-2.column;
```

We need to see the name of each book and the corresponding Price. We can run the following command:

```
SELECT Book.name, Price.price
FROM Book
LEFT JOIN Price
ON Book.id = Price.id;
```

This returns the following:

[![PostgreSQL Left Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ6.png)

All the 4 rows in the Book table have been returned. Only 3 rows from the Price table met the join condition. Hence they were returned. The last book has no corresponding price value.

### PostgreSQL Right Outer Join

The RIGHT OUTER JOIN returns all rows in the table on the right-hand side and rows in the table on the left-hand side where the join condition has been satisfied.

**Syntax:**

```
SELECT columns
FROM table-1
RIGHT OUTER JOIN table-2
ON table-1.column = table-2.column;
```

**For example:**

```
SELECT Book.name, Price.price
FROM Book
RIGHT JOIN Price
ON Book.id = Price.id;
```

This returns the following:

[![PostgreSQL Right Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ7.png)

All the rows in the Price table have been returned. Only the rows in the Book table that met the join condition were returned. The 3rd row has no value for name since no match was found.

### Full Outer Join in PostgreSQL

This type of JOIN will return all rows in the table on the left-hand side and all rows in the table on the right-hand side with nulls where the join condition is not satisfied.

**Syntax:**

```
SELECT columns
FROM table-1
FULL OUTER JOIN table-2
ON table-1.column = table-2.column;
```

**For example:**

```
SELECT Book.name, Price.price
FROM Book
FULL OUTER JOIN Price
ON Book.id = Price.id;
```

This returns the following:

[![PostgreSQL Full Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ8.png)

All rows from all tables have been returned, with nulls where no match was found.

## Using pgAdmin

The above tasks can be accomplished in pgAdmin as follows. The following sections walk through each join type step by step.

## pgAdmin Inner Join

The steps below show how to run each inner join variant in pgAdmin.

### How To Use Theta Join in PostgreSQL using pgAdmin

Below are the steps to use Theta Join in PostgreSQL using pgAdmin:

**Step 1) Login to your pgAdmin account**

Open pgAdmin and Login using your credentials

**Step 2) Create Demo database**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin Inner Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ9.png)

**Step 3) Type the query**

Type the below query in the query editor:

```
SELECT Book.name, Price.price
FROM Book
INNER JOIN Price
ON Book.id = Price.id;
```

**Step 4) Execute the query**

Click the Execute button

[![pgAdmin Inner Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ10.png)

It should return the following:

[![pgAdmin Inner Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ11.png)

### EQUI Join

**Step 1)** Login to your pgAdmin account.

**Step 2)**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin EQUI Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ12.png)

**Step 3)** Type the query in the query editor:

```
SELECT *
FROM Book
JOIN Price ON Book.id = Price.id;
```

**Step 4)** Click the Execute button.

[![pgAdmin EQUI Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ13.png)

It should return the following:

[![pgAdmin EQUI Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ14.png)

### Natural Join

**Step 1)** Login to your pgAdmin account.

**Step 2)**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin Natural Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ15.png)

**Step 3)** Type the query in the query editor:

```
SELECT *
FROM Book
NATURAL JOIN Price;
```

**Step 4)** Click the Execute button.

[![pgAdmin Natural Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ16.png)

It should return the following:

[![pgAdmin Natural Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ17.png)

### pgAdmin Simple Inner Join

**Step 1)** Login to your pgAdmin account.

**Step 2)**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin Simple Inner Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ18.png)

**Step 3)** Type the query in the query editor:

```
SELECT Book.name, Price.price
FROM Book
INNER JOIN Price
ON Book.id = Price.id;
```

**Step 4)** Click the Execute button.

[![pgAdmin Simple Inner Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ19.png)

It should return the following:

[![pgAdmin Simple Inner Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ20.png)

**Don't Miss:**

- [PostgreSQL Tutorial for Beginners](https://www.guru99.com/postgresql-tutorial.html)
- [PostgreSQL Union, Union ALL with Examples](https://www.guru99.com/postgresql-union-example.html)
- [PostgreSQL EXISTS with SELECT Operator (Example)](https://www.guru99.com/postgresql-exists.html)
- [PostgreSQL INSERT: Inserting Data into a Table](https://www.guru99.com/postgresql-insert.html)

## pgAdmin Outer Join

Next, run the three outer join variants in pgAdmin using the steps below.

### Left Outer Join

**Step 1)** Login to your pgAdmin account.

**Step 2)**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin Left Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ21.png)

**Step 3)** Type the query in the query editor:

```
SELECT Book.name, Price.price
FROM Book
LEFT JOIN Price
ON Book.id = Price.id;
```

**Step 4)** Click the Execute button.

[![pgAdmin Left Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ22.png)

It should return the following:

[![pgAdmin Left Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ23.png)

### Right Outer Join

**Step 1)** Login to your pgAdmin account.

**Step 2)**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin Right Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ24.png)

**Step 3)** Type the query in the query editor:

```
SELECT Book.name, Price.price
FROM Book
RIGHT JOIN Price
ON Book.id = Price.id;
```

**Step 4)** Click the Execute button.

[![pgAdmin Right Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ25.png)

It should return the following:

[![pgAdmin Right Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ26.png)

### Full Outer Join

**Step 1)** Login to your pgAdmin account.

**Step 2)**

- From the navigation bar on the left- Click Databases.
- Click Demo.

[![pgAdmin Full Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ27.png)

**Step 3)** Type the query in the query editor:

```
SELECT Book.name, Price.price
FROM Book
FULL OUTER JOIN Price
ON Book.id = Price.id;
```

**Step 4)** Click the Execute button.

[![pgAdmin Full Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ28.png)

It should return the following:

[![pgAdmin Full Outer Join]()](https://www.guru99.com/images/1/102319_0522_PostgreSQLJ29.png)

[Download the Database used in this Tutorial](https://drive.google.com/uc?export=download&id=1BqQSvYTmNz4hvZok7iYG9ha_o48_VF2b)

## FAQs

🎯 What is the difference between INNER JOIN and OUTER JOIN in PostgreSQL?

An INNER JOIN returns only rows that match in both tables. An OUTER JOIN also keeps unmatched rows, filling missing columns with NULL, and can be left, right, or full depending on which table is preserved.

➕ What is the difference between a JOIN and a UNION?

A JOIN combines columns from different tables side by side using a matching key, widening each row. A UNION stacks the rows of two result sets vertically and requires the same number of columns.

🔁 What is a self join in PostgreSQL?

A self join joins a table to itself using two table aliases. It is useful for comparing rows within one table, such as matching employees to the managers stored in the same table.

✖️ What is a CROSS JOIN in PostgreSQL?

A CROSS JOIN returns the Cartesian product, pairing every row of the first table with every row of the second. It uses no ON condition, so it can produce very large result sets quickly.

🔗 Can you join more than two tables in one query?

Yes. You can chain several JOIN clauses in one query, adding each extra table with another JOIN and ON condition. PostgreSQL evaluates them in order to build a single combined result set.

🤖 How can AI help write PostgreSQL JOIN queries?

AI assistants like GitHub Copilot suggest the correct join type, write the ON condition from foreign keys, and flag a missing condition that would cause an accidental Cartesian product, reducing common join mistakes.

🧠 Can AI tools optimize slow PostgreSQL joins?

Yes. AI assistants can read a query plan, recommend indexes on join columns, and rewrite join order or conditions. The database still enforces correctness, so review each suggestion before running it in production.

⚡ Which PostgreSQL join type performs best?

No single join is always fastest; performance depends on indexes, row counts, and filters. INNER JOINs on indexed keys are usually efficient, while FULL OUTER JOINs on large unindexed tables tend to be the costliest.

#### Summarize this post with:

ChatGPTPerplexityGrokGoogle AI

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.**

##### Sign up for the newsletter

Subscribe for Free

You have successfully subscribed.  
Please check your inbox.

![AI-Newsletter]() Chosen by over **350,000+** professionals

[Scroll to top](#wrapper)

×

Search for:

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/postgresql-join-types.png","url":"https://www.guru99.com/images/postgresql-join-types.png","width":"700","height":"250","caption":"PostgreSQL Join Types","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/postgresql-joins-left-right.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/postgresql","name":"PostgreSQL"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/postgresql-joins-left-right.html","name":"PostgreSQL Join Types: Inner, Outer, Left, Right"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/postgresql-joins-left-right.html#webpage","url":"https://www.guru99.com/postgresql-joins-left-right.html","name":"PostgreSQL Join Types: Inner, Outer, Left, Right","dateModified":"2026-10-08T17:07:37+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/postgresql-join-types.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/postgresql-joins-left-right.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/editorial","name":"Editorial Team","url":"https://www.guru99.com/author/editorial","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/favicon-new-logo.png","url":"https://www.guru99.com/images/favicon-new-logo.png","caption":"Editorial Team","inLanguage":"en-US"},"sameAs":["https://www.guru99.com/editorial-team"],"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"PostgreSQL","headline":"PostgreSQL Join Types: Inner, Outer, Left, Right","description":"In this PostgreSQL Joins tutorial, we will learn What are PostgreSQL Joins, Types of PostgreSQL Joins like Inner, Outer, Left, &amp; Right with Example.","keywords":"postgresql, sql","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/editorial","name":"Editorial Team"},"dateModified":"2026-10-08T17:07:37+05:30","image":{"@id":"https://www.guru99.com/images/postgresql-join-types.png"},"copyrightYear":"2026","name":"PostgreSQL Join Types: Inner, Outer, Left, Right","subjectOf":[{"@type":"HowTo","name":"How To Use Theta Join in PostgreSQL using pgAdmin","description":"Below are the steps to use Theta Join in Postgres using pgAdmin:","step":[{"@type":"HowToStep","name":"Step 1) Login to your pgAdmin account","text":"Open pgAdmin and Login using your credentials","url":"https://www.guru99.com/postgresql-joins-left-right.html#step1"},{"@type":"HowToStep","name":"Step 2) Create Demo database","text":"From the navigation bar on the left- Click Databases and then Click Demo","image":"https://cdn.guru99.com/images/1/102319_0522_PostgreSQLJ9.png","url":"https://www.guru99.com/postgresql-joins-left-right.html#step2"},{"@type":"HowToStep","name":"Step 3) Type the query","text":"Type the below query in the query editor:","url":"https://www.guru99.com/postgresql-joins-left-right.html#step3"},{"@type":"HowToStep","name":"Step 4) Execute the query","text":"Click the Execute button","image":"https://cdn.guru99.com/images/1/102319_0522_PostgreSQLJ10.png","url":"https://www.guru99.com/postgresql-joins-left-right.html#step4"}]},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between INNER JOIN and OUTER JOIN in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"An INNER JOIN returns only rows that match in both tables. An OUTER JOIN also keeps unmatched rows, filling missing columns with NULL, and can be left, right, or full depending on which table is preserved."}},{"@type":"Question","name":"What is the difference between a JOIN and a UNION?","acceptedAnswer":{"@type":"Answer","text":"A JOIN combines columns from different tables side by side using a matching key, widening each row. A UNION stacks the rows of two result sets vertically and requires the same number of columns."}},{"@type":"Question","name":"What is a self join in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"A self join joins a table to itself using two table aliases. It is useful for comparing rows within one table, such as matching employees to the managers stored in the same table."}},{"@type":"Question","name":"What is a CROSS JOIN in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"A CROSS JOIN returns the Cartesian product, pairing every row of the first table with every row of the second. It uses no ON condition, so it can produce very large result sets quickly."}},{"@type":"Question","name":"Can you join more than two tables in one query?","acceptedAnswer":{"@type":"Answer","text":"Yes. You can chain several JOIN clauses in one query, adding each extra table with another JOIN and ON condition. PostgreSQL evaluates them in order to build a single combined result set."}},{"@type":"Question","name":"How can AI help write PostgreSQL JOIN queries?","acceptedAnswer":{"@type":"Answer","text":"AI assistants like GitHub Copilot suggest the correct join type, write the ON condition from foreign keys, and flag a missing condition that would cause an accidental Cartesian product, reducing common join mistakes."}},{"@type":"Question","name":"Can AI tools optimize slow PostgreSQL joins?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI assistants can read a query plan, recommend indexes on join columns, and rewrite join order or conditions. The database still enforces correctness, so review each suggestion before running it in production."}},{"@type":"Question","name":"Which PostgreSQL join type performs best?","acceptedAnswer":{"@type":"Answer","text":"No single join is always fastest; performance depends on indexes, row counts, and filters. INNER JOINs on indexed keys are usually efficient, while FULL OUTER JOINs on large unindexed tables tend to be the costliest."}}]}],"@id":"https://www.guru99.com/postgresql-joins-left-right.html#schema-59923","isPartOf":{"@id":"https://www.guru99.com/postgresql-joins-left-right.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/postgresql-joins-left-right.html#webpage"}}]}
```
