sql 多行合一行

sql多行合并成一行

sql server

SELECT [activityId],
--STUFF(
(SELECT ',' + Cast(A.phone AS varchar)
FROM aaa A
WHERE A.activityId=B.activityId
FOR XML PATH(''))
--,1,1,'') AS phones
FROM aaa B
GROUP BY [activityId]

mysql

SELECT
activityId,
group_concat(DISTINCT phone ORDER BY phone DESC SEPARATOR ';') AS phones
FROM
aaa 
GROUP BY
activityId

上一篇:OC 图片圆角实现


下一篇:ThreadPoolExecutor类