Concatenate strings. This function joins two or more string arguments into a single string. Returns NULL if any argument is NULL.
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:
CONCAT() returns NULL if any argument is NULL.
A NULL parameter hides all information contained in other parameters from the result. Sometimes this is not desirable; to avoid this, you can:
Use the function with an empty separator, because that function is NULL-safe.
Use to turn NULLs into empty strings.
In , CONCAT ignores .
Using IFNULL() to handle NULL values:
In :
This page is licensed: GPLv2, originally from
CONCAT(str1,str2,...)SELECT CONCAT(CAST(int_col AS CHAR), char_col);SELECT CONCAT('Ma', 'ria', 'DB');
+---------------------------+
| CONCAT('Ma', 'ria', 'DB') |
+---------------------------+
| MariaDB |
+---------------------------+
SELECT CONCAT('Ma', 'ria', NULL, 'DB');
+---------------------------------+
| CONCAT('Ma', 'ria', NULL, 'DB') |
+---------------------------------+
| NULL |
+---------------------------------+
SELECT CONCAT(42.0);
+--------------+
| CONCAT(42.0) |
+--------------+
| 42.0 |
+--------------+SELECT CONCAT('The value of @v is: ', IFNULL(@v, ''));
+------------------------------------------------+
| CONCAT('The value of @v is: ', IFNULL(@v, '')) |
+------------------------------------------------+
| The value of @v is: |
+------------------------------------------------+SELECT CONCAT('Ma', 'ria', NULL, 'DB');
+---------------------------------+
| CONCAT('Ma', 'ria', NULL, 'DB') |
+---------------------------------+
| MariaDB |
+---------------------------------+