日期:2014-05-18  浏览次数:20399 次

遇到个查询难题。
a 表 b 表 c表 


a 里面包括b和c表里面的一些数据,我要筛选出a表中不包含b和c表中的数据。

select * from a where email not in (select email from b)


目前只实现了去除包含b表里面的数据,我想同时去除b和c表里面的数据,该如何写?请教各位大侠了。

------解决方案--------------------
SQL code

select * from a where not exists(select 1 from b where email=a. email) and not exists(select 1 from c where email=a. email)

------解决方案--------------------
1.select * from a where email not in (select email from b) and email not in(elect email from c)
lz这样不好使么。
------解决方案--------------------
select * from a 
where not exists(select 1 from b where a.email=b.email)
and not exists(select 1 from c where a.email=c.email)

------解决方案--------------------
SQL code
select * from a  
where not exists(select 1 from b where a.email=b.email)
and not exists(select 1 from c where a.email=c.email)

select a.* from a  
join b
on a.email=b.email
join c
on a.email=c.email
where b.email is null and c.email is null