首页 文章

访问2016 - 比较两个表并使用查询返回匹配的记录

提问于
浏览
0

我的目标是创建一个查询,宏或任何可以执行下述任务的解决方案 .

  • 假设我有一个名为"student"的访问2016表,其中有12条记录,如下所示:

enter image description here

  • 然后,假设我有一个名为"matchme"的第二个表,其中有4条记录,如下所示:

enter image description here

我需要找到一种方法

=>首先,创建一个返回“gradu_date”结果的查询等于表“学生”的日期“1/31/2017” .

=>第二,从第一步返回的结果,创建一个查询,将“student”表中的“email”与“matchme”表中的“email”进行比较,并返回[匹配]记录结果 .

所以期望的结果是:

enter image description here
自两个表格中都有电子邮件gary@xxx.com和thomas@xxx.com .

我该如何创建这样的查询?

你可以从这里下载我的访问文件:experiment.accdb

2 回答

  • 1

    简单:

    select * from student 
    inner join matchme on student.email = matchme.email                       
    where student.graduation_date  = '1/31/2017'
    
  • 1

    查看数据样本,您需要在两个表之间 Build 日期和名称的连接

    select * from student 
    inner join matchme on student.graduation_date = matchme.graduation_date 
                            and student.email = matchme.email
    
    where student.graduation_date  = '1/31/2017'
    

相关问题