with HrmResource(id,lastname) as (
select 167,'段秋月' union all
select 170,'杨子军'
)
,formtable_main_78(Requestid,WTCW,XMCY) as (
select 722,'xxxxx公司','167,170'
)
select a.*,stuff(c.[col],1,1,'') [项目名称]
from formtable_main_78 a
cross apply
(select ','+lastname from HrmResource b
where charindex(','+convert(varchar,b.id)+',',','+a.XMCY+',')>0
for xml path('')) c([col])
结果:
设计这样的表的人都很牛逼
这是谁设计的表结构?