Hi,
CONCAT() and
CONCAT_WS() function
CONCAT() Function Code:
Syntax
CONCAT(str1,str2,...)
This function eeturns 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.
CONCAT() returns NULL if any argument is NULL. Example: Code:
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() Function Code:
Syntax
CONCAT_WS(separator,str1,str2,...)
CONCAT_WS() function for Concatenate 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.
Note: CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument. Code:
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' Thanks
R.Gopi.