数据库一列拼接成一个字符串

sqlserver:

SELECT
*,
( SELECT Hospitalproperty2 + ' ' FROM testtable WHERE Hospitalproperty = 'zhangs' FOR XML path ( '' ) ) 
FROM
testtable

 


MySQL:

select *,(select GROUP_CONCAT(b.Hospitalproperty2)from testtable b) from testtable;

 

posted @ 2018-02-28 15:22  天涯韵  阅读(248)  评论(0编辑  收藏  举报