VeloDB Cloud
SQL Reference
SQL Functions
Scalar Functions
Array Functions
ARRAY_UNION

ARRAY_UNION

Description

Merge multiple arrays without duplicate elements to generate a new array

Syntax

ARRAY_UNION(<array>, <array> [, ... ])

Parameters

ParameterDescription
<array>The array to be merged

Return Value

Returns an array containing all elements in the union of all arrays, excluding duplicates. If the input parameter is NULL, it returns NULL.

Example

SELECT ARRAY_UNION([1, 2, 3, 6],[1, 2, 5]),ARRAY_UNION([1, 4, 3, 5, NULL],[1,6,10]);
+--------------------------------------+---------------------------------------------+
| array_union([1, 2, 3, 6], [1, 2, 5]) | array_union([1, 4, 3, 5, NULL], [1, 6, 10]) |
+--------------------------------------+---------------------------------------------+
| [3, 2, 1, 6, 5]                      | [null, 10, 3, 1, 6, 4, 5]                   |
+--------------------------------------+---------------------------------------------+