Mysql 字符串函数

concat_ws()是MySQL的一个字符串函数。此方法用于拼接多个字符串,它有一个分隔符参数,返回分隔符拼接的多个字符串。

语法

select concat_ws(separator,str1,str2,...);  

参数

separator:分隔符

str1:  字符串1

str2:字符串2

示例 1

select concat_ws(',','Id','Password','Name');  

输出:

mysql> select concat_ws(',','Id','Password','Name');
+---------------------------------------+
| concat_ws(',','Id','Password','Name') |
+---------------------------------------+
| Id,Password,Name                      |
+---------------------------------------+
1 row in set (0.00 sec)

示例 2

select concat_ws(',','Name','Class','School');  

输出:

mysql> select concat_ws(',','Name','Class','School');
+----------------------------------------+
| concat_ws(',','Name','Class','School') |
+----------------------------------------+
| Name,Class,School                      |
+----------------------------------------+
1 row in set (0.00 sec)