Concatenation Operator


concatenation_operator ::= "||"

concatenate_expression ::= add_expression ("||" add_expression)*


The concatenation operator returns the character string made by joining the operands in the given order. The operands can be of any* type. For more details, see the concat Function section.


According to the operator precedence, the || operator is immediately after +, - (as binary operators).

Example 6-43 Concatenation Operator

This example joins id, firstname, and lastname into a single string and provides the output. Notice that id, which is an integer type, also gets concatenated with the string values.

SELECT id || firstname || lastname AS name FROM users;
 |    name     |
 | 10JohnSmith |
 | 30PeterPaul |
 | 20MaryAnn   |