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

三张表关联查询
现在有三张表,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)