云数据库 GAUSSDB-数组函数:array_positions(anyarray, anyelement)

时间:2025-06-03 09:32:39

array_positions(anyarray, anyelement)

描述:返回作为第一个参数给出的数组中所有出现的第二个参数的下标的数组。

返回类型:int[]

示例:

gaussdb=# SELECT array_positions(array[1, 2, 3, 1], 1) AS RESULT;
 result 
--------
 {1,4}
(1 row)
  • 数组必须是一维的。
  • 第二个参数可以设置为NULL。
  • 如果数组中找不到第二个参数,返回空数组。
support.huaweicloud.com/distributed-devg-v8-gaussdb/gaussdb-12-2645.html