现有2张表,A表中有一字段bm(身份证编码),B表中有一字段sfzbm(身份证编码).现在想将A与 B中身份证编码不一致的查询出来,如何写语句.谢谢!
select bm from a
union
select sfzbm from b
minus
(select bm from a,b where a.bm=b.sfzbm);
union
select sfzbm from b
minus
(select bm from a,b where a.bm=b.sfzbm);
温馨提示:答案为网友推荐,仅供参考
第1个回答 2009-06-25
用表链接
第2个回答 2009-06-25
select * from A where bm not in (select bm from B)
第3个回答 2009-06-25
两张表都有姓名吗?
第4个回答 2009-06-25
select dm from A except(select sfzbm from B)
第5个回答 2009-06-25
select bm from A where bm not in (select sfzbm from B)
union all
select sfzbm from B where sfzbm not in (select bm from A)
union all
select sfzbm from B where sfzbm not in (select bm from A)