Tips > Building Workflows

Use the Merge Node to Enrich Records with Data from a Second Source

The Merge node combines data from two branches by matching on a shared key.

The Merge node combines data from two branches by matching on a shared key. This is the n8n equivalent of a SQL JOIN and is the standard way to enrich records from one system with data from another. Fetch the base records in one branch, fetch the enrichment data in a parallel branch, and merge them by a common identifier.

Real-world example: You have a list of orders from Shopify and need to enrich each order with customer lifetime value (CLV) data from your analytics database.

Trigger
  |
  +-> Branch 1: Shopify - Get Recent Orders
  |     (returns: order_id, customer_email, total, created_at)
  |
  +-> Branch 2: PostgreSQL - Get Customer CLV
  |     (returns: email, lifetime_value, order_count, first_order_date)
  |
  Merge Node
    Mode:       Combine
    Join:       Inner Join (or Left Join to keep unmatched orders)
    Match By:   Field
    Field 1:    customer_email  (from Shopify branch)
    Field 2:    email           (from PostgreSQL branch)
```text
```sql title="PostgreSQL Node Query"
SELECT
  email,
  SUM(total_amount) as lifetime_value,
  COUNT(*) as order_count,
  MIN(created_at) as first_order_date
FROM orders
GROUP BY email;
```text
```json title="Merged Output (one item)"
{
  "order_id": "ORD-5678",
  "customer_email": "jane@example.com",
  "total": 89.99,
  "created_at": "2025-01-15T10:30:00Z",
  "lifetime_value": 1247.50,
  "order_count": 14,
  "first_order_date": "2023-03-22T08:15:00Z"
}
```text
> **Tip: Merge Mode Reference**
>
> - **Inner Join:** Only items with matches in both branches (drops unmatched).
> - **Left Join:** All items from Branch 1, enriched with Branch 2 data where available (unmatched items have null enrichment fields).
> - **Append:** Combine all items from both branches into a single list (no matching, just concatenation).

The enriched data can now be used downstream: high-CLV customers get priority processing, first-time buyers get a welcome email, repeat customers get a loyalty discount.

**Related:** [Use Path Parameters in Webhook URLs for Dynamic Routing](../webhook-mastery/01-use-path-parameters-in-webhook-urls-for-dynamic-routing.md) | [Use Edit Fields in "Map Each" Mode for Simple Renames](../data-transformation/01-use-edit-fields-in-map-each-mode-for-simple-renames.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