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 joins data from two branches on a shared key, the n8n equivalent of a SQL JOIN. Fetch base records in one branch and enrichment data in a parallel branch, then merge them by a common field such as email. The mode you choose, Inner Join, Left Join, or Append, decides which items survive and how unmatched rows are handled.

What does the Merge node do?

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.

How do you set up a two-branch enrichment merge?

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)

The enrichment branch aggregates customer lifetime value with a query like this:

SELECT
  email,
  SUM(total_amount) as lifetime_value,
  COUNT(*) as order_count,
  MIN(created_at) as first_order_date
FROM orders
GROUP BY email;

Each order is then merged with its matching customer record, producing an enriched 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"
}

What is the difference between the merge modes?

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 · Use Edit Fields in "Map Each" Mode for Simple Renames

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

190 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 an introductory call