CONCAT(str1,str2,...)
Returns the string that results from concatenating the arguments. Returns
NULL if any argument is
NULL. 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 explicit type cast, like in this example: SELECT
CONCAT(CAST(int_col AS CHAR), char_col)
mysql> SELECT
CONCAT('My', 'S', 'QL');
-> 'MySQL'
mysql> SELECT
CONCAT('My',
NULL, 'QL');
->
NULL
mysql> SELECT
CONCAT(14.3);
-> '14.3'
CONCAT_WS(separator,str1,str2,...)
CONCAT_WS() stands for
CONCAT With Separator and is a special form of
CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string as can the rest of the arguments. If the separator is
NULL, the result is
NULL. The function skips any
NULL values after the separator argument.
mysql> SELECT CONCAT_WS(',','First name','Second name','Last Name');
-> 'First name,Second name,Last Name'
mysql> SELECT CONCAT_WS(',','First name',
NULL,'Last Name');
-> 'First name,Last Name'
Before MySQL 4.0.14, CONCAT_WS() skips empty strings as well as
NULL values.