CONCAT()

Description

This function CONCAT() returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string.

CONCAT() returns NULL if any argument is NULL.

Syntax

  1. >
  2. CONCAT(str1,str2,...)

Arguments

ArgumentsDescription
str1,str2,…Required. The str to add together.
Note: If any of the strs is a NULL value, it returns NULL.

Examples

  1. mysql> SELECT CONCAT('My', 'S', 'QL');
  2. +-------------------+
  3. | concat(My, S, QL) |
  4. +-------------------+
  5. | MySQL |
  6. +-------------------+
  7. 1 row in set (0.01 sec)
  8. mysql> SELECT CONCAT('My', NULL, 'QL');
  9. +----------------------+
  10. | concat(My, null, QL) |
  11. +----------------------+
  12. | NULL |
  13. +----------------------+
  14. 1 row in set (0.00 sec)

Constraints

Currently, CONCAT() doesn’t support quoted strings and numeric argument.