About

In formal language theory and computer programming, string concatenation is the operation of joining two character strings end-to-end. For example, the concatenation of snow and ball is snowball.

In many programming languages, string concatenation is a binary infix operator. The + operator is often overloaded to denote concatenation for string arguments: "Hello, " + "World"; has the value "Hello, World".

Comparison of different SQL implementations on CONCATENATION

Standard     Core feature ID E021-07:
             Concatenating two strings is done with the || operator:
             string1 || string2
             If at least one operand is NULL, then the result is NULL.


PostgreSQL   Follows the standard.
             Automatically casts the concatenated values into types compatible with concatenation. If an operand is NULL then the result is NULL.


DB2         Follows the standard, partly.
            Does not automatically cast concatenated values into compatible types.


MSSQL    Breaks the standard by using the '+' operator instead of '||'.
          Does not automatically cast operands to compatible types. If an operand is NULL, then the result is NULL.


MySQL    Badly breaks the standard by redefining || to mean OR.
         Offers instead a function, CONCAT(string, string), which accepts two or more arguments.
         Automatically casts values into types which can be concatenated. If an operand is NULL, then the result is NULL.


Oracle   Follows the standard, partly.
         Automatically casts values into types which can be concatenated.    
         As Oracle interprets NULL as the empty string, it doesn't return NULL if an operand is NULL.


Informix    Follows the standard.
         Automatically casts numeric data into character data, if needed. If an operand is NULL then the result is NULL.
history | show excerpt | excerpt history