首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

查询的结果用逗号联接 有图

2013-12-06 
查询的结果用逗号连接 有图SQL怎样写能变成下面这张图[解决办法]create table #table(baomingzy varchar(5

查询的结果用逗号连接 有图

查询的结果用逗号联接 有图

SQL怎样写能变成下面这张图

查询的结果用逗号联接 有图
[解决办法]

create table #table(baomingzy varchar(50),call_user varchar(50))

insert into #table
select '','jiangbingyu' union all
select '','jiangshengnan' union all
select '','menglingjun' union all
select '办公自动化','jiangshengnan' union all
select '初级会计实务','jiangshengnan' union all
select '电脑应用高级班','jiangshengnan' union all
select '海洋自动化精+串','jiangshengnan' union all
select '会计就业直通班','jiangshengnan' union all
select '会计学串讲','jiangshengnan' union all
select '中级会计师','jiangshengnan' union all
select '专升本VF+英语','jiangshengnan' 

select distinct
(select stuff((
select ','+baomingzy from #table b where a.call_user=b.call_user
for xml path('')),1,1,''))baomingzy
,call_user
from #table a

baomingzy                                                                                                                                                                                                                                                        call_user
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------
                                                                                                                                                                                                                                                                 jiangbingyu
                                                                                                                                                                                                                                                                 menglingjun


,办公自动化,初级会计实务,电脑应用高级班,海洋自动化精+串,会计就业直通班,会计学串讲,中级会计师,专升本VF+英语                                                                                                                                                                                                      jiangshengnan

(3 行受影响)

热点排行