当前位置: 代码迷 >> Sql Server >> 遇到个查询难题。该如何处理
  详细解决方案

遇到个查询难题。该如何处理

热度:39   发布时间:2016-04-27 14:53:26.0
遇到个查询难题。
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 bon a.email=b.emailjoin con a.email=c.emailwhere b.email is null and c.email is null
  相关解决方案