首页 / MYSQL / MySQL行列转换拼接
MySQL行列转换拼接
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MySQL行列转换拼接,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3076字,纯文字阅读大概需要5分钟。
内容图文
![MySQL行列转换拼接](/upload/InfoBanner/zyjiaocheng/453/f3d1607b929e418da0121197448256cd.jpg)
*************************** 1. row ***************************
TBL_ID: 6
CREATE_TIME: 1437309077
LAST_ACCESS_TIME: 0
TBL_NAME: students
TBL_TYPE: MANAGED_TABLE
*************************** 2. row ***************************
TBL_ID: 11
CREATE_TIME: 1437402612
LAST_ACCESS_TIME: 0
TBL_NAME: user_info_bucketed_1
TBL_TYPE: MANAGED_TABLE
2 rows in set (0.00 sec)
mysql> select * from user_info;
+---------+-----------+-----------+
| user_id | firstname | lastname |
+---------+-----------+-----------+
| 100 | Hadoop | Spark01 |
| 100 | Hadoop | Spark02 |
| 100 | Hadoop | Spark03 |
| 200 | Hive | Python2.6 |
| 200 | Hive | Python2.7 |
| 200 | Hive | Python3.3 |
| 200 | Hive | Python3.4 |
| 300 | HBase | Pig |
| 300 | HBase | Zoo |
+---------+-----------+-----------+
9 rows in set (0.00 sec)
mysql> select user_id,group_concat(firstname) from user_info group by user_id;
+---------+-------------------------+
| user_id | group_concat(firstname) |
+---------+-------------------------+
| 100 | Hadoop,Hadoop,Hadoop |
| 200 | Hive,Hive,Hive,Hive |
| 300 | HBase,HBase |
+---------+-------------------------+
3 rows in set (0.06 sec)
mysql> select user_id,group_concat(lastname) from user_info group by user_id;
+---------+-----------------------------------------+
| user_id | group_concat(lastname) |
+---------+-----------------------------------------+
| 100 | Spark01,Spark02,Spark03 |
| 200 | Python2.6,Python2.7,Python3.3,Python3.4 |
| 300 | Pig,Zoo |
+---------+-----------------------------------------+
3 rows in set (0.00 sec)
mysql> select user_id,group_concat(lastname separator ‘;‘) from user_info group by user_id;
+---------+-----------------------------------------+
| user_id | group_concat(lastname separator ‘;‘) |
+---------+-----------------------------------------+
| 100 | Spark01;Spark02;Spark03 |
| 200 | Python2.6;Python2.7;Python3.3;Python3.4 |
| 300 | Pig;Zoo |
+---------+-----------------------------------------+
3 rows in set (0.00 sec)
mysql> select user_id,group_concat(lastname order by lastname desc separator ‘#‘) from user_info group by user_id;
+---------+-------------------------------------------------------------+
| user_id | group_concat(lastname order by lastname desc separator ‘#‘) |
+---------+-------------------------------------------------------------+
| 100 | Spark03#Spark02#Spark01 |
| 200 | Python3.4#Python3.3#Python2.7#Python2.6 |
| 300 | Zoo#Pig |
+---------+-------------------------------------------------------------+
3 rows in set (0.00 sec)
MySQL行列转换拼接
标签:
本文系统来源:http://www.cnblogs.com/wwxbi/p/4663149.html
内容总结
以上是互联网集市为您收集整理的MySQL行列转换拼接全部内容,希望文章能够帮你解决MySQL行列转换拼接所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。