Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | About

54.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;