📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ARRAY_APPEND



Appends an element to the end of an array.

Syntax

ARRAY_APPEND(array, element)

Parameters

ParameterDescription
arrayThe source array to which the element will be appended.
elementThe element to append to the array.

Return Type

Array with the appended element.

Notes

This function works with both standard array types and variant array types.

Examples

Example 1: Appending to a Standard Array

SELECT ARRAY_APPEND([1, 2, 3], 4);

Result:

[1, 2, 3, 4]

Example 2: Appending to a Variant Array

SELECT ARRAY_APPEND(PARSE_JSON('[1, 2, 3]'), 4);

Result:

[1, 2, 3, 4]

Example 3: Appending Different Data Types

SELECT ARRAY_APPEND(['a', 'b'], 'c');

Result:

["a", "b", "c"]

Was this page helpful?