- Categories:
String & binary functions (General)
CONCAT , ||¶
Concatenates one or more strings, or concatenates one or more binary values.
The || operator provides alternative syntax for CONCAT and requires at least two arguments.
- See also:
Syntax¶
Arguments¶
exprThe input expressions must be all strings, or all binary values.
Returns¶
The data type of the returned value is the same as the data type of the input values.
If any input value is NULL, the function returns NULL.
Usage notes¶
Metadata functions such as GET_DDL accept only constants as input. Concatenated input generates an error.
Collation details¶
The collation specifications of all input arguments must be compatible.
The collation of the result of the function is the highest-precedence collation of the inputs.
Examples¶
Concatenate two strings:
Concatenate five strings, using session variables for three of them:
Concatenate two VARCHAR columns. First, create a table and insert data:
Run a query:
Concatenate more than two strings:
Use the IFF function with the CONCAT function to concatenate strings that are not NULL:
Use the || concatenation operator instead of the function: