日期:2014-05-17 浏览次数:20434 次
create table #c(email varchar(10))
insert into #c values ('1@abc.com')
insert into #c values ('12@a.com')
insert into #c values ('3@@b.com')
insert into #c values ('123@d.com')
insert into #c values ('1@sina.com')
create table #b(domain varchar(10))
insert into #b values('abc.com')
insert into #b values('a.com')
insert into #b values('b.com')
select *
from #c
where RIGHT(email,len(email)-CHARINDEX('@',email,1)) in (select domain from #b)
create table #c(email varchar(10))
insert into #c values ('1@abc.com')
insert into #c values ('12@a.com')
insert into #c values ('3@@b.com')
insert into #c values ('123@d.com')
insert into #c values ('4@b.com')
insert into #c values ('123@@A.com')
insert into #c values ('1@sina.com')
create table #b(domain varchar(10))
insert into #b values('abc.com')
insert into #b values('a.com')
insert into #b values('b.com')
select c.email
from #c c left join #b b on c.email like '%@'+b.domain
where b.domain is not null
create table #c(email varchar(10))
insert into #c values ('1@abc.com')
insert into #c values ('12@a.com')
insert into #c values ('3@@b.com')
insert into #c values ('123@d.com')
insert into #c values ('1@sina.com')
create table #b(domain varchar(10))
insert into #b values('abc.com')
insert into #b values('a.com')
insert into #b values('b.com')
select *
from #c
where exists(select 1 from #b where #c.email like '%@'+domain)
/*
1@abc.com
12@a.com
3@@b.com
*/
--create table #c(email varchar(10))
--insert into #c values ('1@abc.com')
--insert into #c values ('12@a.com')
--insert into #c values ('3@@b.com')
--insert into #c values ('123@d.com')
--insert into #c values ('1@sina.com')
--create table #b(domain varchar(10))
--insert into #b values('abc.com')
--insert into #b values('a.com')
--insert into #b values('b.com')
SELECT *
FROM #c
WHERE EXISTS ( SELECT 1
FROM &nbs