> For the complete documentation index, see [llms.txt](https://couchbase.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://couchbase.shujuwajue.com/n1ql-ji-chu-cao-zuo-jiao-cheng/di-er-zhang-ff1a-joins-lian-jie-cha-xun/27unnest.md).

# 27.UNNEST

UNNEST运算允许您将嵌套的内容提升到与他们的父对象级别，加入他们的父对象。

在tutorial数据库有每个人都有一个children数组。如果我们有三个人,每个都有两个孩子,我们会得到6的结果,每个都包含1人,1的孩子。

右边的查询连接Dave和他的两个孩子。

Query:

```sql
SELECT * 
    FROM tutorial AS parent
        UNNEST parent.children
            WHERE parent.fname = 'Dave'
```

结果：

```javascript
{
  "results": [
    {
      "children": {
        "age": 17,
        "fname": "Aiden",
        "gender": "m"
      },
      "parent": {
        "age": 46,
        "children": [
          {
            "age": 17,
            "fname": "Aiden",
            "gender": "m"
          },
          {
            "age": 2,
            "fname": "Bill",
            "gender": "f"
          }
        ],
        "email": "dave@gmail.com",
        "fname": "Dave",
        "hobbies": [
          "golf",
          "surfing"
        ],
        "lname": "Smith",
        "relation": "friend",
        "title": "Mr.",
        "type": "contact"
      }
    },
    {
      "children": {
        "age": 2,
        "fname": "Bill",
        "gender": "f"
      },
      "parent": {
        "age": 46,
        "children": [
          {
            "age": 17,
            "fname": "Aiden",
            "gender": "m"
          },
          {
            "age": 2,
            "fname": "Bill",
            "gender": "f"
          }
        ],
        "email": "dave@gmail.com",
        "fname": "Dave",
        "hobbies": [
          "golf",
          "surfing"
        ],
        "lname": "Smith",
        "relation": "friend",
        "title": "Mr.",
        "type": "contact"
      }
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://couchbase.shujuwajue.com/n1ql-ji-chu-cao-zuo-jiao-cheng/di-er-zhang-ff1a-joins-lian-jie-cha-xun/27unnest.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.
