lq920320 / blogs

Blogs of personal.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2018/01/18--mysql查询语句合并查询结果

lq920320 opened this issue · comments

在使用查询语句时,有时候需要用到关联查询,查询结果会出现group by一列出现对应数行的情况。
sql如下:
select * from table group by 列字段;
合并查询出的列:
select GROUP_CONCAT(查询的字段 separator ';') from table group by 列字段;
其中GROUP_CONCAT()方法可以直接使用GROUP_CONCAT(cloum)默认以","相隔,亦可以自定义分割符,如GROUP_CONCAT(cloum separator ';')