日期:2014-05-18 浏览次数:20691 次
select b.*,a.名称 from B,A where b.编号=a.编号
------解决方案--------------------
create table a
(
id int,
[name] varchar(30)
)
insert into a
select 1,'跑步机' union all
select 2,'足球'
create table b
(
id int,
dec varchar(200),
[type] varchar(30),
[name] varchar(30)
)
insert into b(id,dec,type)
select 2,'健身','球类'union all
select 1,'健身','器材'
select * from a
select * from b
select STUFF((select ','+name from a a_2 where a_2.id=a.id for xml path('')),1,1,'') as [name] from a group by id
update b set[name]=(select a.name from a where a.id=b.id)
from a where b.id=a.id
drop table a
drop table b