?????????????????SQL?????????SQL???????????????????????????????SQL?????????????????????????????SQL Server?????????????????????????????????????????????????????????????С?????????????????????ū??????????????????????????????????????????????????????????????飩????????????????????????????????????????
????????????????????????????
CREATE TABLE [dbo].tab_1(
[Id] [int] NOT NULL??
[SkillId] [int] NOT NULL
) ON [PRIMARY]
CREATE TABLE [dbo].tab_2(
[Id] [int] NOT NULL??
[SkillId] [int] NOT NULL
) ON [PRIMARY]
GO
insert into tab_1 values(1??1)
insert into tab_1 values(1??2)
insert into tab_1 values(2??1)
insert into tab_1 values(2??3)
insert into tab_1 values(2??6)
insert into tab_2 values(5??1)
insert into tab_2 values(5??2)
insert into tab_2 values(5??4)
insert into tab_2 values(7??1)
insert into tab_2 values(7??3)
insert into tab_2 values(7??6)
????????????????£?

????????1??????????????????????????????????????????????????^_^????

?????????????Id??????tab_1??tab_2??????????SkillId?????
????????????????÷??顢???????????????????и???????????????????????????????·???????????????????饗?????????????????????????????ú???е?????????????????£?
????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 cte1.Skills=cte2.Skills
????????????????????????????????????????tab_1?????У?
????insert into tab_1 values(2??5)