---
schema_version: "1"
id: 82322e78c30d81bc192eb8e5804a19283b181ad4f12f7175d5a2bf8a1f2836fd
title: join
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-arrays-functions-join.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-arrays-functions-join
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 71e7ea87d9fe4aa759bd3f13316f3f09100a9a01a67f367d777148bdfc43a69e
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# join

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## join(Array<L>, Array<R>, (leftValue: L) -> String, (rightValue: R) -> String): Array<Pair<L, R>>

Joins two arrays of objects by a given ID criteria.

`join` returns an array all the `left` items, merged by ID with any right items that exist.

_Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>left</code></p></td><td><p>The left-side array of objects.</p></td></tr><tr><td><p><code>right</code></p></td><td><p>The right-side array of objects.</p></td></tr><tr><td><p><code>leftCriteria</code></p></td><td><p>The criteria used to extract the ID for the left collection.</p></td></tr><tr><td><p><code>rightCriteria</code></p></td><td><p>The criteria used to extract the ID for the right collection.</p></td></tr></tbody></table>

### Example

This example shows how join behaves. Notice that the output only includes objects where the values
of the input `user.id` and `product.ownerId` match. The function includes the `"l"` and `"r"` keys
in the output.

#### Source

```DataWeave
 %dw 2.0
 import * from dw::core::Arrays
 var users = [{id: "1", name:"Mariano"},{id: "2", name:"Leandro"},{id: "3", name:"Julian"},{id: "5", name:"Julian"}]
 var products = [{ownerId: "1", name:"DataWeave"},{ownerId: "1", name:"BAT"}, {ownerId: "3", name:"DataSense"}, {ownerId: "4", name:"SmartConnectors"}]
 output application/json
 ---
 join(users, products, (user) -> user.id, (product) -> product.ownerId)
```

#### Output

```json
[
  {
    "l": {
      "id": "1",
      "name": "Mariano"
    },
    "r": {
      "ownerId": "1",
      "name": "DataWeave"
    }
  },
  {
    "l": {
      "id": "1",
      "name": "Mariano"
    },
    "r": {
      "ownerId": "1",
      "name": "BAT"
    }
  },
  {
    "l": {
      "id": "3",
      "name": "Julian"
    },
    "r": {
      "ownerId": "3",
      "name": "DataSense"
    }
  }
]
```
