如何获得MS Access中一个表中没有的所有行? [英] How do I get all the rows in one table that are not in another in MS Access?

查看:85
本文介绍了如何获得MS Access中一个表中没有的所有行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了很多不同的方法,但是总是会出现语法错误.

I have tried a bunch of different things but always get syntax errors.

我有两个表-tableA和tableB.它们都具有con_number字段作为唯一ID. 我想选择tableB中所有不存在于tableA中的行.

I have two tables - tableA and tableB. They both have a con_number field as a unique ID. I want to select all of the rows in tableB that do not exist in tableA.

有人可以给我这个查询,就像在MS Access中一样吗?

Can anyone please give me this query as it would be in MS Access?

我知道在这种情况下使用NOT IN效率很低,因此,如果有更好的方法,那会很棒.

I know that using NOT IN is quite inefficient in this case so if there is a better way then that would be great.

谢谢.

推荐答案

SELECT TableB.con_number
FROM TableB
WHERE NOT EXISTS (SELECT 1 
                  FROM TableA 
                  WHERE TableA.con_number = TableB.con_number);

这篇关于如何获得MS Access中一个表中没有的所有行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆