# Union Introduction

### Introduction

A Union of 2 or more tables allows you to combine rows from different tables into a single result set or “stack” tables one on another. In this tutorial, we will discuss the concept of union and provide an example to illustrate the process.

#### An Overview

Tabula Union works similarly to the SQL UNION operator, but with more flexibility. It can combine tables that have different column sets by matching columns based on their names and data types. The column order in the original tables does not matter. This feature makes union tables a powerful tool for merging data from various sources with varying structures.

**Example**.&#x20;

Consider the following two tables:

Table A:

| id | name       | age | country |
| -- | ---------- | --- | ------- |
| 1  | John Smith | 34  | USA     |
| 2  | Jane Doe   | 28  | UK      |

Table B:

| country | id | city        | name        |
| ------- | -- | ----------- | ----------- |
| USA     | 3  | Los Angeles | Mike Brown  |
| UK      | 4  | London      | Emma Watson |

Although the columns in both tables are not in the same order, the union tool can combine them based on the matching column names and data types.

Result:

| id | name        | age  | country | city        |
| -- | ----------- | ---- | ------- | ----------- |
| 1  | John Smith  | 34   | USA     | NULL        |
| 2  | Jane Doe    | 28   | UK      | NULL        |
| 3  | Mike Brown  | NULL | USA     | Los Angeles |
| 4  | Emma Watson | NULL | UK      | London      |

In the resulting union table, the matched columns (id, name, and country) are combined, while the columns with no match in the other table (age and city) are filled with NULL values.


---

# 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://docs.tabula.io/tutorials/union-introduction.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.
