当前位置: 代码迷 >> Sql Server >> 三张表关联查询解决方案
  详细解决方案

三张表关联查询解决方案

热度:137   发布时间:2016-04-27 19:20:13.0
三张表关联查询
现在有三张表,1.2.3,都有身份证这个字段。
想查出表3中的记录,既不在表1中,也不在表2中的数据。
怎么写sql?请指教
谢谢!

------解决方案--------------------
SQL code
 
select c.* from c where sfz not in (select sfz from a union select sfz from b) t


--or

select * from t a
where not exists(select 1 from t1 where sfz=a.sfz)
and  not exists(select 1 from t2 where sfz=a.sfz)
  相关解决方案