查询表:
id title
1 title1
2 title2
3 title3
要求现实:
title1,title2,title3
select stuff((select ','+title from tb for xml path('')),1,1,'')
mb61d995c26a1bb 博主文章分类:SQL
查询表:
id title
1 title1
2 title2
3 title3
要求现实:
title1,title2,title3
select stuff((select ','+title from tb for xml path('')),1,1,'')
是这样的,这个需求应该还是会常有的,特别是当你收集到的数据不规范的时候。有些人自认为自己很聪明,给的数据很漂亮,看上去一目了然,它不知道这些数据还要用来分析出来的,当要用的时候,很难受,正如下面这样的数据,一个人对应几个省,个数还不一样。看上去是不是既优雅又美观,但是你要怎么操作呢,我要每个省的数据,每个省然后对应哪些人。这个时候你不会操作怎么办?是不是很难受,下面有几个思路可以借鉴
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M