mysql处理函数

1.concat_ws

CONCAT_WS(separator,str1,str2,...)

CONCAT_WS() 代表 CONCAT With Separator ,是CONCAT()的特殊形式。第一个参数是其它参数的分隔符。分隔符的位置放在要连接的两个字符串之间。分隔符可以是一个字符串,也可以是其它参数。
注意:
如果分隔符为 NULL,则结果为 NULL。函数会忽略任何分隔符参数后的 NULL 值。

2.group_concat

利用group_concat()方法,参数为需要合并的字段,合并的字段分隔符默认为逗号,可通过参数separator指定,该方法往往配合group by 一起使用。

select group_concat(T.area) as area from (select notice_id,concat_ws('-',province,city) as area from dbzhb.admin_notice_user where province<>'') T 

原文地址:https://www.cnblogs.com/sign-ptk/p/6636603.html