sql 同时查询2个表中字段值是否相等

现有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);
温馨提示:答案为网友推荐,仅供参考
第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)

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网