???1?????T-SQL????
???????????? ???????[ 2015/6/18 15:31:25 ] ????????????? SQL Server
????????2??????????????????
?????????????Id??????ж?tab_1??????????SkillId???????????tab_2??????????SkillId???????????÷?????????????????
?????????????????????????charindex??????
with cte1 as(
select Id?? stuff((select '??'+ CONVERT(varchar??SkillId) from tab_1 t where t.Id=t1.Id for xml path(''))??1??1??'') as Skills from tab_1 t1
group by Id
)??
cte2 as(
select Id?? stuff((select '??'+ CONVERT(varchar??SkillId) from tab_2 tt where tt.Id=tt1.Id for xml path(''))??1??1??'') as Skills from tab_2 tt1
group by Id
)select * from cte1 join cte2 on CHARINDEX(cte2.Skills??cte1.Skills)=1
????????????????SQL Server??for xml path()????У?stuff()???????????????charindex()?????????????????????
???????????@С?????@С???????????·??
????1.??2????????????????????????????????????
????2.????1??2?????????????SkillId???б????????????1??2???????????ν????????????????????????????????
????3.??2?ó??????????????????????????1???????????????????????2?????????>=????T-SQL???£?
with cte1 as(
select id??SkillId??count(1) over (partition by Id) as count1 from tab_1
)??cte2 as(
select id??SkillId??count(1) over (partition by Id) as count2 from tab_2
)??cte3 as(
select cte1.Id??cte1.Skillid??count1??cte2.Id as Id2??cte2.SkillId as SkillId2??cte2.count2??
COUNT(1) over (partition by cte1.Id??cte2.Id) as count3
from cte1 full join cte2
on cte1.SkillId=cte2.SkillId
)select Id??SkillId??Id2??SkillId2 from cte3
where count1=count2 and count3=count2
???????????????????????????????е??ɡ???????????????????????????????м???
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11