---
schema_version: "1"
id: 8eb8af922a5dc4a0e3a55e303f903ff0c66d73102df9dbc47bafd5f942e28c4e
title: outerJoin
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-arrays-functions-outerjoin.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-arrays-functions-outerjoin
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a815df3dfca0efb6b686c6b2f4a764e978680245edf52ce8b04b8d81cd756ed3
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# outerJoin

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

## outerJoin<L <: Object, R <: Object>(left: Array<L>, right: Array<R>, leftCriteria: (leftValue: L) -> String, rightCriteria: (rightValue: R) -> String): Array<{ l?: L, r?: R }>

Joins two array of objects by a given `ID` criteria.

`outerJoin` returns an array with all the `left` items, merged by ID with the `right` items in cases
where any exist, and it returns `right` items that are not present in the `left`.

_Introduced in DataWeave version 2.2.0._

### 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 includes objects where the values of the
input `user.id` and `product.ownerId` match, and it includes objects where there is no match for the
value of the `user.id` or `product.ownerId`.

#### 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
---
outerJoin(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": "2",
      "name": "Leandro"
    }
  },
  {
    "l": {
      "id": "3",
      "name": "Julian"
    },
    "r": {
      "ownerId": "3",
      "name": "DataSense"
    }
  },
  {
    "l": {
      "id": "5",
      "name": "Julian"
    }
  },
  {
    "r": {
      "ownerId": "4",
      "name": "SmartConnectors"
    }
  }
]
```
