多行(结果集)拼接字符串 (多行变一行)

SQL Server版:
select stuff( 
(
	select 
	 ','+odr.ccontact 
	from t_order odr 
	join t_order_tour tot on tot.uteamid='A52D1FB4-64B2-4C04-AD6B-05BC4959BD21' and odr.uid=tot.uorderid 
	for xml path('')
)
,1,1,'') 



Oracle:
SYS_CONNECT_BY_PATH
START WITH pid IS NULL CONNECT BY NOCYCLE PRIOR NO = pid

MySQL:
group_concat

详细可参考 http://www.cnblogs.com/kiant71/archive/2010/04/09/1752006.html

猜你喜欢

转载自benjaminyu.iteye.com/blog/1844268