---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - en/concepts/data-join
  - ru/concepts/data-join
  - href: en/concepts/data-join.md
    type: text/markdown
    title: Markdown version
csp:
  - script-src:
      - https://mc.yandex.ru
    img-src:
      - https://mc.yandex.ru
    connect-src:
      - https://mc.yandex.ru
      - wss://mc.yandex.ru
    child-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-ancestors:
      - 'blob:'
      - https://mc.yandex.ru
canonical: en/concepts/data-join.html
title: Joining DataLens On-premises data
description: >-
  When creating a dashboard in DataLens On-premises, you might want to use a
  link that determines how a selector affects one or more charts and other
  selectors. You can use links to filter the values of selectors and charts.
  This article describes how to join data from different datasets to set up
  links between widgets.
vcsPath: en/concepts/data-join.md
---

# Joining DataLens On-premises data

DataLens On-premises uses a [connection](./connection/index.md) to retrieve data from a source . You can create datasets, charts, and selectors from the connection data. If the source has multiple tables, you can combine them to build the required set of data. You can link data from different datasets at the chart level or through selector links.

## Data joining methods {#data-join}

You can use different data joining methods:

* [Dataset level](#dataset-join)

  * [Adding tables](#ui-join)
  * [SQL query](#sql-join)

* [Chart level](#chart-join)


* [Selector link level](#selector-join)

### Dataset level {#dataset-join}

To join data at the dataset level, you can [add tables](#ui-join) to the workspace or write an [SQL query](#sql-join).

{% note warning %}

You cannot join data from different sources at a single dataset level.

{% endnote %}

#### Adding tables {#ui-join}

You can [join data](../dataset/create-dataset.md#links) through the dataset creation interface by dragging tables to the workspace and configuring links between them using the [JOIN](../dataset/data-model.md#source) operator.

<!-- source: en/_includes/datalens/datalens-data-join-duplicate-fields-note.md -->
{% note info %}

When you merge data from multiple tables, a dataset will get duplicates of the fields used to create links. You can remove them manually from the list of dataset fields. You can also [describe the dataset using an SQL query](../dataset/create-dataset.md#add-data) and exclude duplicate fields from the final set.

{% endnote %}
<!-- endsource: en/_includes/datalens/datalens-data-join-duplicate-fields-note.md -->

#### SQL query {#sql-join}

In a dataset, you can add an [ad-hoc SQL query](../dataset/settings.md#sql-request-in-datatset) to the data source. When accessing a data source, the query code is run as a subquery. You can use the query output as the final dataset or join it with other source tables via the interface.

### Chart level {#chart-join}


To join data at the chart level, you can use a [QL chart](#sql-chart).


#### QL chart {#sql-chart}

[QL charts](chart/index.md#sql-charts) are charts created from a connection if there is a database at the other end of the connection. Running a SQL query does not create a separate dataset object; instead, it generates one on the fly and displays it in the preview panel. For more information, see [Creating a QL chart in DataLens On-premises](../operations/chart/create-sql-chart.md).


### Selector link level {#selector-join}

You can add a selector to a dashboard to modify query output in its associated widgets:

* On the dashboard, selectors and charts built from a single dataset get linked automatically.
* Selectors and charts built from different datasets can be linked manually using aliases.

Before creating a link, make sure the field used by the selector as a filter is present in the dataset the chart is built on. Otherwise, the link will not work. For more information, see [Creating an alias in DataLens On-premises](../operations/dashboard/create-alias.md).


