MS Access 查询显示 table1 中不在 table2 中的行,使用两个字段进行区分。 (左外连接??)

MS Access query to display rows of table1 which are not in table2 using two fields to diferentiate. (Left-Outer-Join??)

Table 1: SalesforceReportWeekly ;字段:[机会:商店编号]、[目标电路完成 (FOC)]、...

Table 2:SentSalesforceReportWeekly 字段:[业务机会:商店编号]、[目标电路完成 (FOC)]、...

我需要一个可以在 MS Access 中运行的查询,它将显示 SalesforceReportWeekly 中在 SentSalesforceReportWeekly 中没有相应行的所有行。使用 [Opportunity: Store Number] 和 [Target Circuit Completion (FOC)] 字段。 [Opportunity: Store Number] 和 [Target Circuit Completion (FOC)] 相同的记录需要从我的结果视图中省略。我的结果视图中需要包含 SalesforceReportWeekly 中与 SentSalesforceReportWeekly 中的记录具有相同商店编号但 [Target Circuit Completion (FOC)] 不同的记录。这必须在 MS Access 中工作。我觉得我什么都试过了:

尝试一:由于某种原因,这 returns 几乎整个 table...

SELECT *
       FROM [SalesforceReportWeekly]
            LEFT OUTER JOIN [SentSalesforceReportWeekly]
                 ON ([SalesforceReportWeekly].[Opportunity: Store Number] = [SentSalesforceReportWeekly].[Opportunity: Store Number] AND [SalesforceReportWeekly].[Target Circuit Completion (FOC)] = [SentSalesforceReportWeekly].[Target Circuit Completion (FOC)])
                     WHERE [SentSalesforceReportWeekly].[Target Circuit Completion (FOC)] IS NULL AND [SentSalesforceReportWeekly].[Opportunity: Store Number] IS NULL;

尝试二:returns 结果视图包含大量空行,但已发送 table 中的行除外。

SELECT * 
       FROM [SalesforceWeeklyReportFutureInstalls]
            LEFT JOIN [SentInstallScheduled] ON ([SalesforceWeeklyReportFutureInstalls].[Opportunity: Store Number] = [SentInstallScheduled].[StoreNumber] AND [SalesforceWeeklyReportFutureInstalls].[Target Circuit Completion (FOC)] = [SentInstallScheduled].[TargetCircuitCompletionFOC])
UNION
SELECT *
       FROM [SalesforceWeeklyReportFutureInstalls]
            RIGHT JOIN [SentInstallScheduled] ON ([SalesforceWeeklyReportFutureInstalls].[Opportunity: Store Number] = [SentInstallScheduled].[StoreNumber] AND [SalesforceWeeklyReportFutureInstalls].[Target Circuit Completion (FOC)] = [SentInstallScheduled].[TargetCircuitCompletionFOC]);

我花了几个小时梳理其他 SO 问题,我发现了其他类似的问题,但是 none 和我的完全一样(两个 table 排除了另一个 table 的结果两个领域)并且未能成功地调整他们的解决方案以满足我的需求。我们将不胜感激任何帮助!

查找在另一个 table 中不存在的行的标准方法是利用 NOT EXISTS:

SELECT *
FROM [SalesforceReportWeekly]
WHERE NOT EXISTS
  (SELECT * FROM [SentSalesforceReportWeekly]
   WHERE [SalesforceReportWeekly].[Opportunity: Store Number] = [SentSalesforceReportWeekly].[Opportunity: Store Number] 
     AND [SalesforceReportWeekly].[Target Circuit Completion (FOC)] = [SentSalesforceReportWeekly].[Target Circuit Completion (FOC)]
  )