Updated on 2026-11-06 GMT+08:00

concat

The concat function is used to concatenate arrays or strings.

Syntax

Input is an array: Concatenates all elements from multiple arrays together to generate a new array.

concat(array , array [,...]) 

Input is a string: Concatenates multiple strings together to generate a new string.

concat(string , string [,...]) 

Parameters

Input is an array

Parameter

Mandatory

Type

Description

a, b

Yes

ARRAY

Arrays. T in array<T> refers to the data type of the elements in the array. Elements in the array can be of any type. The data types of elements in a and b must be consistent. NULL values in the array participate in the operation.

Input is a string

Parameter

Mandatory

Type

Description

str1, str2

Yes

STRING

Strings. If the input parameter is of type BIGINT, DOUBLE, DECIMAL, or DATETIME, it is automatically converted to STRING type before evaluation. Other types will return an error.

Return Values

Returns a value of type ARRAY or STRING.

  • Returns ARRAY type. If any input array is NULL, the return result is NULL.
  • Returns STRING type. If there are no parameters or any parameter is NULL, the return result is NULL.

Example Code

  • Concatenate arrays array(1, 2) and array(2, -2). The command example is as follows.

    Returns [1,2,2,-2].

    select concat(array(1, 2), array(2, -2));
  • Concatenate strings ABC and DEF. The command example is as follows.

    Returns ABCDEF.

    select concat('ABC','DEF');
  • The input is empty. The command example is as follows.
    Returns NULL.
    select concat();
  • Any input string is NULL. The command example is as follows.

    Returns NULL.

    select concat('abc', 'def', null);