array_concat, ||
array_concat, ||
Section titled “array_concat, ||”Returns a concatenation of two arrays.
The ||
operator provides alternative syntax for ARRAY_CONCAT and can concatenate more than two arrays.
Syntax
Section titled “Syntax”array_concat( <array1> , <array2> )
Arguments
Section titled “Arguments”<array1>
Section titled “<array1>”The source array.
<array2>
Section titled “<array2>”The array to be appended to <array1>
.
Returns
Section titled “Returns”An ARRAY containing the elements from <array2>
appended after the elements of <array1>
.
If any input value is NULL, returns NULL.
Examples
Section titled “Examples”This example shows how to use array_concat
:
VALUES ([1, 2], [3, 4])SELECT array_concat([1, 2], [3, 4]);
+------------------------------+| array_concat([1, 2], [3, 4]) |+------------------------------+| [1,2,3,4] |+------------------------------+
Use the ||
concatenation operator instead of the function:
SELECT [1, 2, 3] || [] || ["other", "solutions"];
+-------------------------------------------+| [1, 2, 3] || [] || ['other', 'solutions'] |+-------------------------------------------+| [1,2,3,'other','solutions'] |+-------------------------------------------+