# right\_join

Joins two arrays based on matching keys, similar to SQL RIGHT JOIN. All items from the second array are kept, with matching properties merged from the first array. Non-matching items get `null` values for the first array's properties.

```liquid
{% json employees %}
  [
    { "id": 1, "name": "Ann", "department_id": 10 },
    { "id": 2, "name": "Adam", "department_id": 20 }
  ]
{% endjson %}

{% json departments %}
  [
    { "dept_id": 10, "dept_name": "Accounting", "floor": 3 },
    { "dept_id": 20, "dept_name": "Sales", "floor": 5 },
    { "dept_id": 30, "dept_name": "Marketing", "floor": 7 }
  ]
{% endjson %}

{% assign result = employees | right_join: departments, "department_id = dept_id" %}
{% log result %}
```

Results in following output:

```json
[
  {
    "dept_id": 10,
    "dept_name": "Accounting",
    "floor": 3,
    "id": 1,
    "name": "Ann",
    "department_id": 10
  },
  {
    "dept_id": 20,
    "dept_name": "Sales",
    "floor": 5,
    "id": 2,
    "name": "Adam",
    "department_id": 20
  },
  {
    "dept_id": 30,
    "dept_name": "Marketing",
    "floor": 7,
    "id": null,
    "name": null
  }
]
```

#### Syntax

```liquid
{{ array1 | right_join: array2, "key1 = key2" }}
```

| Parameter | Description                      |
| --------- | -------------------------------- |
| `array1`  | Array to join from               |
| `array2`  | Primary array (all items kept)   |
| `key1`    | Property name in array1 to match |
| `key2`    | Property name in array2 to match |

#### Notes

* Modifies `array2` in place
* Unmatched items receive `null` for properties from `array1` (excluding the join key)
* See also: `left_join` for keeping all items from the first array instead


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datajet-app.com/liquid/filters/right_join.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
