???1?????T-SQL????
???????????? ???????[ 2015/6/18 15:31:25 ] ????????????? SQL Server
?????????????????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)
??????
???·???
??????????????????
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