Concatenation Operator
Syntax
concatenation_operator ::= "||"
concatenate_expression ::= add_expression
("||" add_expression)*
Semantics
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.
Note:
According to the operator precedence, the || operator is immediately after +, - (as binary operators).Example 6-84 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 |
+-------------+