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





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
SQL 自然语言处理 关系型数据库
【Hive】函数 concat 、concat_ws 、concat_group 的区别
【Hive】函数 concat 、concat_ws 、concat_group 的区别
1381 0
|
8月前
|
Java 关系型数据库 MySQL
面试官:GROUP BY和DISTINCT有什么区别?
面试官:GROUP BY和DISTINCT有什么区别?
189 0
面试官:GROUP BY和DISTINCT有什么区别?
|
SQL 分布式计算 Spark
SPARK Expand问题的解决(由count distinct、group sets、cube、rollup引起的)
SPARK Expand问题的解决(由count distinct、group sets、cube、rollup引起的)
831 0
SPARK Expand问题的解决(由count distinct、group sets、cube、rollup引起的)
|
12月前
ROW_NUMBER() OVER()函数用法详解 (分组排序 例子多)
ROW_NUMBER() OVER()函数用法详解 (分组排序 例子多)
181 0
|
SQL 关系型数据库 MySQL
MySQL中concat()、concat_ws()、group_concat()三个函数的使用技巧案例与心得总结
MySQL中concat()、concat_ws()、group_concat()三个函数的使用
395 0
MySQL中concat()、concat_ws()、group_concat()三个函数的使用技巧案例与心得总结
|
存储 SQL 关系型数据库
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column的解决办法
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column的解决办法
570 0
group by+group_concat解决的小问题
group by+group_concat解决的小问题
152 0
|
SQL 关系型数据库 MySQL
【已解决】SELECT list is not in GROUP BY clause and contains nonaggregated column
MySQL5.7.5后only_full_group_by成为sql_mode的默认选项之一,这可能导致一些sql语句失效。
628 0
|
关系型数据库 MySQL
十一、GROUP_CONCAT的使用
十一、GROUP_CONCAT的使用
530 0
|
SQL 关系型数据库 MySQL
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
458 0