Multiple lines of MySQL and SQL Server merged into one line
MySQL Multi-line merge:
MySQL built-in function group_concat (exper SEPARATOR "")
Exper: set forth
SEPARATOR "": line delimiter, which means separating multiple lines with a space
Mysql> select * from tmp_02;
+------------+---------+
| fclient | CT |
+------------+---------+
| Android | 1858799 |
| IOS | 522568 |
| Legendary Client | 472561 |
+------------+---------+
3 Rows in Set (0.00 sec)
Multi-line Merge:
Mysql> Select CONVERT (Group_concat (CONCAT (fclient, ': ', CT) SEPARATOR "") using UTF8) TKey from tmp_02;
+-----------------------------------------------+
| TKey |
+-----------------------------------------------+
| Android: 1858799 ios:522568 legendary client: 472561 |
+-----------------------------------------------+
1 row in Set (0.00 sec)
Note: The line delimiter can be any character.
Reference Link: http://blog.sina.com.cn/s/blog_4e808acf01009qna.html
In SQL Server, a previous version of 2000 (including 2000) requires the ability to manually write a function that implements a multiline merge row.
Since 2005 (including 2005) the functionality of the built-in for XML path makes it easy to implement multiple rows of merged lines
Example:
Select EventClass from Dbo.perfom
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/47/B7/wKioL1P-xuKhIbyIAAC7JjzI-xk552.jpg "title=" 1.jpg " alt= "Wkiol1p-xukhibyiaac7jjzi-xk552.jpg"/>
Select (select CAST (eventclass as varchar) + '; '
From DBO.PERFOM FOR XML Path (")) as A
Results:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/47/B7/wKioL1P-xvexgxmmAADLVoeDZv0372.jpg "title=" 2.jpg " alt= "Wkiol1p-xvexgxmmaadlvoedzv0372.jpg"/>
Reference links for the FOR XML path:
Http://www.cnblogs.com/doubleliang/archive/2011/07/06/2098775.html
This article is from the "SQL Server MySQL" blog, so be sure to keep this source http://dwchaoyue.blog.51cto.com/2826417/1546125
Multiple lines of MySQL and SQL Server merged into one line