# append-datatables

## Description

<mark style="color:purple;">`append-datatables`</mark> *adaptor combines rows from two datatables into one datatable.*

The output datatable includes all rows from the `first` datatable followed by all rows from `second` datatable. The number of rows in the output datatable will be exactly the sum of the rows in `first` datatable and `second` datatable.

By default, the output datatable will include all columns from both datatables, this can be changed by setting `exclude unmatched columns` to true to exclude columns which do not exist in both datatables.

This adaptor is similar to a [SQL UNION Operator](https://www.w3schools.com/sql/sql_union.asp), please consider using the [<mark style="color:purple;">`join-datatables`</mark> ](/data-flo/reference-guide/join-datatables.md)adaptor to perform a [SQL JOIN](https://www.w3schools.com/sql/sql_join.asp) operation.

## Inputs

**`first data`**\
Type: `datatable`\
Required: Yes\
The first datatable.

**`second data`**\
Type: `datatable`\
Required: Yes\
The second datatable.

**`exclude unmatched columns`**\
Type: `boolean`\
Required: No\
Specifies whether to exclude columns which do not exist in both datatables. If unspecified, defaults to `False` (all columns from both datatables will be included).

## Outputs

**`data`**\
Type: `datatable`\
A datatable containing rows from both datatables.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`first data`:

<table><thead><tr><th width="119.33333333333334">Month</th><th width="129">Sales (USD)</th><th width="129">Sales (GBP)</th></tr></thead><tbody><tr><td>Jan</td><td>1458</td><td>1156</td></tr><tr><td>Feb</td><td>9874</td><td>7835</td></tr></tbody></table>

`second data`:

<table><thead><tr><th width="142.33333333333334">Month</th><th width="128">Sales (USD)</th><th width="132">Sales (EUR)</th></tr></thead><tbody><tr><td>Mar</td><td>4562</td><td>4173</td></tr><tr><td>Apr</td><td>3654</td><td>3342</td></tr></tbody></table>

`exclude unmatched columns:` *null(empty)*

#### Outputs:

`data`:

<table><thead><tr><th width="239">Month</th><th width="129">Sales (USD)</th><th width="122">Sales (GBP)</th><th width="127">Sales (EUR)</th></tr></thead><tbody><tr><td>Jan</td><td>1458</td><td>1156</td><td></td></tr><tr><td>Feb</td><td>9874</td><td>7835</td><td></td></tr><tr><td>Mar</td><td>4562</td><td></td><td>4173</td></tr><tr><td>Apr</td><td>3654</td><td></td><td>3342</td></tr></tbody></table>

-> Appended two datatables and included the unmatched columns.

### Example 2: Excluding unmatched columns.

#### Inputs:

`first data`:

<table><thead><tr><th width="107.33333333333334">Month</th><th width="129">Sales (USD)</th><th width="129">Sales (GBP)</th></tr></thead><tbody><tr><td>Jan</td><td>1458</td><td>1156</td></tr><tr><td>Feb</td><td>9874</td><td>7835</td></tr></tbody></table>

`second data`:

<table><thead><tr><th width="125.33333333333334">Month</th><th width="128">Sales (USD)</th><th width="132">Sales (EUR)</th></tr></thead><tbody><tr><td>Mar</td><td>4562</td><td>4173</td></tr><tr><td>Apr</td><td>3654</td><td>3342</td></tr></tbody></table>

`exclude unmatched columns`: True

#### Outputs:

`data`:

<table><thead><tr><th width="165">Month</th><th width="127">Sales (USD)</th></tr></thead><tbody><tr><td>Jan</td><td>1458</td></tr><tr><td>Feb</td><td>9874</td></tr><tr><td>Mar</td><td>4562</td></tr><tr><td>Apr</td><td>3654</td></tr></tbody></table>

-> Appended two datatables and excluded the unmatched columns.

## Use cases

* Users are able to combine results from multiple sources.
* Users can add additional observations or records to an existing datatable.
* Users can combine time-series data from different time periods.


---

# Agent Instructions: 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:

```
GET https://cgps.gitbook.io/data-flo/reference-guide/append-datatables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
