concat_ws function in MySQL

This article introduces the use of the concat_ws function in MySQL through examples,
such as select concat_ws(',','11','22','33').
How to
use :
CONCAT_WS(separator,str1,str2,...)
CONCAT_WS() stands for CONCAT With Separator, that is, a string connection with separators , which is a special form of CONCAT().
The first parameter is the delimiter for other parameters. The position of the separator is placed between the two strings to be concatenated.
The delimiter can be a string or other parameters.
Note:
If the delimiter is NULL, the result is NULL. The function ignores NULL values ​​after any delimiter argument.

Unlike concat, the concat_ws function will not return NULL because of the NULL value when executing,

such as: select concat_ws(',','11','22',NULL); 

+-------- -----------------------+ 
| concat_ws(',','11','22',NULL) | 
+------- ------------------------+ 
| 11, 



mysql> select concat_ws(',','11','22','33');
+---------------------------- ----+
| concat_ws(',','11','22','33') |
+---------------------------- -------+
| 11,22,33 |
+-------------------------------+
1 row The difference between in set (0.00 sec)
and the concat function in MySQL is that the concat_ws function will not return NULL because of the NULL value when it is executed.
mysql> select concat_ws(',','11','22',NULL);
+-------------------------------+
| concat_ws(',','11','22',NULL) |
+-------------------------------+
| 11,22 |
+---------- ---------------------+
1 row in set (0.00 sec)

from: http://www.poluoluo.com/jzxy/200812/53697.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326733032&siteId=291194637