例1:基本使用
select concat (id, username, password) as info from my_test;
?...例3:我们使用concat_ws()将 分隔符指定为逗号,达到与例2相同的效果:
select concat_ws(',', id,username,password) as info from my_test...三、group_concat()函数
前言:在有group by的查询语句中,select指定的字段要么就包含在group by语句的后面,作为分组的依据,要么就包含在聚合函数中。...例5:查询该数据并根据性别分组:
select sex, id, username from my_test group by sex;
?...——使用group_concat()
例6:查询数据分组并获取每个组别中详细的数据:
select sex, group_concat(id) as ids, group_concat(username