Tips > Data, APIs & Webhooks

Use the Merge Node's Combine Mode with Key Matching to Join Data

The Merge node in **Combine > Merge By Fields** mode performs the equivalent of a SQL JOIN between two n8n data streams.

The Merge node in Combine > Merge By Fields mode performs the equivalent of a SQL JOIN between two n8n data streams. This is essential whenever you need to enrich records from one source with data from another.

Real-world example: Input 1 contains customer records from your CRM (HubSpot). Input 2 contains recent order data from your database. You want to merge them on email to produce an enriched customer record.

Workflow structure:

[HubSpot Node] ──────► [Merge Node] ──────► [Output]
                           ▲
[Postgres Node] ───────────┘
```text
Configure the Merge node:

| Setting                | Value                              |
|------------------------|------------------------------------|
| Mode                   | Combine                            |
| Combination Mode       | Merge By Fields                    |
| Input 1 Field          | `email`                            |
| Input 2 Field          | `customer_email`                   |
| Output Type            | Keep Matches                       |
| Clash Handling         | Prefer Input 2 (order data wins)   |

```json
// Input 1 (HubSpot) item:
{ "email": "jane@acme.com", "name": "Jane Doe", "lifecycle_stage": "customer" }

// Input 2 (Postgres) item:
{ "customer_email": "jane@acme.com", "last_order_date": "2025-03-15", "total_spent": 4250.00 }

// Merged output:
{
  "email": "jane@acme.com",
  "name": "Jane Doe",
  "lifecycle_stage": "customer",
  "last_order_date": "2025-03-15",
  "total_spent": 4250.00
}
```text
> **Note: Handling Unmatched Records**
>
> Set **Output Type** to **Keep Everything** if you want to include customers who have no orders (a LEFT JOIN equivalent). Unmatched fields will be `null`.

This replaces what would otherwise be a complex Code node with nested loops and is significantly easier to maintain.

**Related:** [Flatten Deeply Nested API Responses](../code-node-mastery/01-flatten-deeply-nested-api-responses.md) | [Use the HTTP Request Node as a Universal Connector](../integration-patterns/01-use-the-http-request-node-as-a-universal-connector.md)

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

191 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book a 20-minute call