- Categories:
Semi-structured and structured data functions (Array/Object)
ARRAY_TO_STRING¶
Returns an input array converted to a string by casting all values to strings (using TO_VARCHAR) and concatenating them (using the string from the second argument to separate the elements).
Syntax¶
Arguments¶
arrayThe array of elements to convert to a string.
separator_stringThe string to put between each element, typically a space, comma, or other human-readable separator.
Returns¶
This function returns a value of type VARCHAR.
Usage notes¶
A NULL argument returns NULL as a result.
A NULL in an array is converted to an empty string in the result.
To include a blank space between values, you must precede the space with the separator character (e.g.
', '). See the examples below.
Examples¶
Return various arrays as concatenated strings:
This example returns an array that contains a NULL value as a concatenated string. First, create a table and insert an array:
Return the array as a concatenated string: