> ## Documentation Index
> Fetch the complete documentation index at: https://docs.less.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Combine

> Merge datasets horizontally

The Combine tool is probably the most important and used tool in Less. It is used to merge datasets horisontally via one of more IDs.

<Tip>
  The Combine is called a Join in SQL, Merge in Pandas and XLOOKUP in Excel.
</Tip>

Imagine you have two lists of friends - one list has their names and favorite colors, and another list has their names and favorite foods. A Combine is like putting these lists together by matching the names! You get three results: friends who appear in both lists (with all their info), friends who only appear in the first list, and friends who only appear in the second list. It's like making a super list that has everything from both your original lists!

In technical terms, the Combine tool outputs three anchors - just like how we got three different friend lists in our example above. That means you can easily access the rows that combine, the ones that don't combine from the **left** dataset and the ones that don't combine from the **right** dataset.

<Frame>
  <img src="https://mintcdn.com/less-51/ZjPXJAIsRGCMglYF/images/tools/combine/Anchors.gif?s=4a2944404c4fe2d1103030de76c77550" width="2000" height="1254" data-path="images/tools/combine/Anchors.gif" />
</Frame>

## Configuration

Note that the *L* and *R* of the Combine anchors refers to *left table* and *right table* respectively.

<Steps>
  <Step title="ID columns">
    Choose which columns to use as ID columns. The right column refers to the R anchor and the left column refers to the L anchor.

    <Note>
      The ID columns must be the same data type.
    </Note>

    You can add as many ID columnn pars as you need with the "+ Add pair"-button. Check out the examples below.
  </Step>

  <Step title="Suffix (optional)">
    You can choose to add a suffix to the output columns. This is useful if you potentially have duplicate columns in your datasets.
  </Step>

  <Step title="Output columns (optional)">
    You can choose to select the output columns in dataset. This is like a built-in [Columns](../basics/columns) tool (though slightlty less sophiscated).
  </Step>
</Steps>

### Example: Single ID column

Here we have a simple example where we want to combine on *text\_col* (L) and *combineCol1* (R).

We deselect a lot of columns from the left dataset while we're at it.

<Tabs>
  <Tab title="Left dataset">
    <img className="rounded-md" src="https://mintcdn.com/less-51/7hAaZrB-cL9KB8SD/images/tools/combine/1left.png?fit=max&auto=format&n=7hAaZrB-cL9KB8SD&q=85&s=ca23d4415305a01b11503a02f02d15c4" width="3786" height="730" data-path="images/tools/combine/1left.png" />
  </Tab>

  <Tab title="Right dataset">
    <img className="rounded-md" src="https://mintcdn.com/less-51/7hAaZrB-cL9KB8SD/images/tools/combine/1right.png?fit=max&auto=format&n=7hAaZrB-cL9KB8SD&q=85&s=661457b5966352f2dca5b4c3e791296f" width="3784" height="632" data-path="images/tools/combine/1right.png" />
  </Tab>

  <Tab title="Output">
    <img className="rounded-md" src="https://mintcdn.com/less-51/7hAaZrB-cL9KB8SD/images/tools/combine/1out.png?fit=max&auto=format&n=7hAaZrB-cL9KB8SD&q=85&s=05b23bf7aaf726fe3b16f0f571db5c9f" width="2194" height="1556" data-path="images/tools/combine/1out.png" />
  </Tab>
</Tabs>

### Example: Multiple ID columns

Here we combine with two column pairs. Notice how - as opposed to the example above - we only match a single row because this row matches both of our column pairs.

<Tabs>
  <Tab title="Left dataset">
    <img className="rounded-md" src="https://mintcdn.com/less-51/7hAaZrB-cL9KB8SD/images/tools/combine/2left.png?fit=max&auto=format&n=7hAaZrB-cL9KB8SD&q=85&s=700679e016733230dd09862e4c1efe60" width="3786" height="730" data-path="images/tools/combine/2left.png" />
  </Tab>

  <Tab title="Right dataset">
    <img className="rounded-md" src="https://mintcdn.com/less-51/7hAaZrB-cL9KB8SD/images/tools/combine/1right.png?fit=max&auto=format&n=7hAaZrB-cL9KB8SD&q=85&s=661457b5966352f2dca5b4c3e791296f" width="3784" height="632" data-path="images/tools/combine/1right.png" />
  </Tab>

  <Tab title="Output">
    <img className="rounded-md" src="https://mintcdn.com/less-51/7hAaZrB-cL9KB8SD/images/tools/combine/2out.png?fit=max&auto=format&n=7hAaZrB-cL9KB8SD&q=85&s=08067d6cc5d3901cd1ef9a7fe386aa6e" width="2194" height="1556" data-path="images/tools/combine/2out.png" />
  </Tab>
</Tabs>
