如何基于两个条件从MS Access中的多个表中查找重复的记录 [英] How to find out duplicate records from multiple tables in MS Access based on two condition

查看:138
本文介绍了如何基于两个条件从MS Access中的多个表中查找重复的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据月份和以下各列从MS Access的多个表中查找重复记录? 名称,文字,说明,TestDescription

How to find out duplicate records from multiple tables in MS Access based on month and the below columns ? Name, Text, Description, TestDescription

select [table1].[Name], [table1].[Text], [table1].[Description], [table1].[TestDescription] 
From [table1]
UNION ALL 
select  [table2].[Name], [table2].[Text], [table2].[Description], [table2].[TestDescription]
from [table2]
WHERE Table1.month IN ("April","May") and Table2.month IN ("April","May")
group by [table1].[Name], [table1].[Text], [table1].[Description], [table1].[TestDescription]
having count(*) > 1;

推荐答案

基于您对发布的第一个答案的评论,如果您实际上是在根据提及的四个字段查找两个表中都出现的记录,则可以使用join,例如:

Based on your comments to the first answer posted, if you are actually looking to find records which appear in both tables based on the four fields you mention, you could use a join, e.g.:

select t1.*
from 
    table1 t1 inner join table2 t2 on
    t1.name = t2.name and 
    t1.text = t2.text and
    t1.description = t2.description and
    t1.testdescription = t2.testdescription
where
    t1.month in ("April", "May")

这篇关于如何基于两个条件从MS Access中的多个表中查找重复的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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