---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.4
alternate:
  - https://ydb.tech/docs/en/dev/yql-tutorial/join_tables.md
  - https://ydb.tech/docs/ru/dev/yql-tutorial/join_tables.md
sourcePath: en/core/dev/yql-tutorial/join_tables.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# Joining tables with JOIN

Merge the columns of the source tables `seasons` and `series`, then output all the seasons of the IT Crowd series to the resulting table using the [JOIN](https://ydb.tech/docs/en/yql/reference/syntax/select/join.md) operator.

<!-- source: en/dev/yql-tutorial/_includes/yql_tutorial_prerequisites.md -->
{% note info %}

We assume that you already created tables in step [Creating a table](https://ydb.tech/docs/en/dev/yql-tutorial/create_demo_tables.md) and populated them with data in step [Adding data to a table](https://ydb.tech/docs/en/dev/yql-tutorial/fill_tables_with_data.md).

{% endnote %}
<!-- endsource: en/dev/yql-tutorial/_includes/yql_tutorial_prerequisites.md -->

```yql
SELECT
    sa.title AS season_title,    -- sa and sr are "join names",
    sr.title AS series_title,    -- table aliases declared below using AS.
    sr.series_id,                -- They are used to avoid
    sa.season_id                 -- ambiguity in the column names used.

FROM
    seasons AS sa
INNER JOIN
    series AS sr
ON sa.series_id = sr.series_id
WHERE sa.series_id = 1
ORDER BY                         -- Sorting of the results.
    sr.series_id,
    sa.season_id                 -- ORDER BY sorts the values by one column
;                                -- or multiple columns.
                                 -- Columns are separated by commas.

COMMIT;
```

