drop table TmpA
drop table TmpB
go
create table TmpA( id nvarchar(50) , name nvarchar(50))
create table TmpB( id nvarchar(50) , name nvarchar(50) )
insert into TmpA values ( 'A' ,'1')
insert into TmpA values ( 'B,C' ,'2')
insert into TmpA values ( 'D,E' ,'3')
insert into TmpA values ( 'D,E,A' ,'4')
insert into TmpA values ( 'D,E,F' ,'5')
insert into TmpB values ( 'A' ,'aaa@mail')
insert into TmpB values ( 'B' ,'bbb@mail')
insert into TmpB values ( 'C' ,'ccc@mail')
insert into TmpB values ( 'D' ,'ddd@mail')
insert into TmpB values ( 'E' ,'eee@mail')
Select A.id , B.id , B.name
From TmpA A Inner Join TmpB B
On A.id Like '%' + B.id +'%'
全站熱搜