适用范围: NoSQL
比较两个集中的表达式,并返回两个集中包含的表达式集(没有重复项)。
语法
SetIntersect(<array_expr_1>, <array_expr_2>)
参数
| 描述 | |
|---|---|
array_expr_1 | 
表达式数组。 | 
array_expr_2 | 
表达式数组。 | 
返回类型
返回表达式数组。
示例
第一个示例使用具有静态数组的函数来演示相交功能。
SELECT VALUE {
    simpleIntersect: SetIntersect([1, 2, 3, 4], [3, 4, 5, 6]),
    emptyIntersect: SetIntersect([1, 2, 3, 4], []),
    duplicatesIntersect: SetIntersect([1, 2, 3, 4], [1, 1, 1, 1]),
    noMatchesIntersect: SetIntersect([1, 2, 3, 4], ["A", "B"]),
    unorderedIntersect: SetIntersect([1, 2, "A", "B"], ["A", 1])
}
[
  {
    "simpleIntersect": [
      3,
      4
    ],
    "emptyIntersect": [],
    "duplicatesIntersect": [
      1
    ],
    "noMatchesIntersect": [],
    "unorderedIntersect": [
      "A",
      1
    ]
  }
]
最后一个示例使用了单个在两个数组属性中共享值的项。
[
  {
    "name": "Snowilla vest",
    "inStockColors": [
      "Rhino",
      "Finch"
    ],
    "colors": [
      "Finch",
      "Mine Shaft",
      "Rhino"
    ],
    "category": "modern-vests"
  }
]
查询从容器中的项中选择相应的字段。
SELECT
    p.name,
    SetIntersect(p.colors, p.inStockColors) AS availableColors
FROM
    products p
WHERE
    p.category = "modern-vests"
[
  {
    "name": "Snowilla vest",
    "availableColors": [
      "Rhino",
      "Finch"
    ]
  }
]
备注
- 此函数不返回重复项。
 - 此函数不使用索引。