Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | About

7.2. group_concat() 列传行

SELECT tags FROM neo.article;

linux
redis
mysql
java
php
		

tags字段专为一行显示

SELECT group_concat(tags) FROM neo.article;		

linux,redis,mysql,java,php
		

distinct 去除重复数据

select group_concat(distinct author) from neo.article;		
		

以id分组,把name字段的值打印在一行,分号分隔

select id,group_concat(tags separator ';') from neo.article group by tags;		
		

排序结果

select group_concat(distinct author order by author desc) from neo.article;