--- title: "Table Joins" slug: "table-joins" updated: 2022-07-06T08:58:36Z published: 2022-07-06T08:58:36Z canonical: "docs.preset.io/table-joins" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.preset.io/llms.txt > Use this file to discover all available pages before exploring further. # Table Joins ## Overview When writing query joins in SQL lab, there are several restrictions: 1. Joined tables must be from the same database. 2. Joined tables can be from different schemas within a database. 3. Joined tables can be from the same schema within a database. --- ## Examples ### Example for Restriction 1 There exists a table called **public.example_one** in a Postgresql database called **post** and another table called **public.example_two** in an Athena database called **ath**. A SQL query such as: ``` SELECT * FROM post.public.example_one JOIN ath.public.example_two ON example_one.id = example_two.id ``` ...will be invalid. Even if the two databases were both Postgresql databases, you will not be able to join. Tables **must** originate from the same database. ### Example for Restriction 2 There exists a table called **schema_one.example_one** and another table called **schema_two.example_two** in the same database. A SQL query such as: ``` SELECT * FROM schema_one.example_one JOIN schema_two.example_two ON example_one.id = example_two.id ``` ...will be valid. ### Example for Restriction 3 There exists a table called **public.example_one** and another table called **public.example_two** in the same database. A SQL query such as: ``` SELECT * FROM public.example_one JOIN public.example_two ON example_one.id = example_two.id ``` ...will be valid. #### Specify the database you are using in SQL Lab From the [SQL Editor](/v1/docs/querying-and-analysis), in the **Database** field, ensure that you specify the database that contains your tables/schemas. ![Screen Shot 2021-08-15 at 10.48.37 PM.png](https://cdn.document360.io/4749ddf8-aa05-4f3f-80e1-07a5d2d0f137/Images/Documentation/Screen%20Shot%202021-08-15%20at%2010.48.37%20PM.png)