> For the complete documentation index, see [llms.txt](https://eleven-fifty-academy.gitbook.io/sql-101-basics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eleven-fifty-academy.gitbook.io/sql-101-basics/part-2-postgresql/2.11-join.md).

# 2.11: Join

In this lesson, you'll learn how to query data from multiple tables. This short [video](https://www.youtube.com/watch?v=ClcqCB4sEEs) will introduce the concept of an "inner join," which is the type of join you'll be using below.\
&#x20;You can also read more about joining tables in PostgreSQL by clicking [here](https://www.postgresql.org/docs/9.2/static/queries-table-expressions.html).

Start by copying and pasting this code into a query in pgAdmin. This will populate the table you created in the previous lesson.

```sql
INSERT INTO Purchases (
    VALUES (1, 1, 1, 5),
    (2, 1, 2, 5),
    (3, 2, 4, 3)
);
```

This is what the resulting table should look like:\
&#x20;

![Purchase table after insert](/files/-LAU8oLhvSSGYMAC7_8U)

Now, write a query that will return a table containing the customer's first names that have a PurchaseID.\
&#x20;You'll have to use an "INNER JOIN" to accomplish this. Remember that you are also working with multiple tables, so consider which tables have the data you are querying for. Finally, think about what columns these tables have in common.<br>

The resulting table output from your query should look like this:&#x20;

![Table output inner join](/files/-LAU8oMTZI_-MnMl0CYU)

To see the solution for this challenge, click on [2.12 Solutions](/sql-101-basics/part-2-postgresql/2.12-solutions.md#211-join-solution).\
&#x20;For additional challenges, please continue to [Part Four](https://github.com/eleven-fifty-academy/sql-101-basics/tree/8405b8de217ee0b340e3d87a9408e4b52270d6ea/PartFour/4.0.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://eleven-fifty-academy.gitbook.io/sql-101-basics/part-2-postgresql/2.11-join.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
