联合多个删除查询或以其他方式合并

联合多个删除查询或以其他方式合并

我有 3 个单独的删除查询,我希望:将它们合并在一起,以便单击一次即可运行它们,或者重写,以便我可以在单个查询中执行所有操作。到目前为止,我还没能做到这一点。查询如下:

删除重复的线索

DELETE WorkBook.*, Exists (select 1 
       from Leads 
WHERE WorkBook.Email=Leads.Email) AS Expr1
FROM WorkBook
WHERE (Exists (select 1 
       from Leads
WHERE WorkBook.Email=Leads.Email));

从工作簿中删除客户

DELETE WorkBook.*, Exists (select 1 
       from Customers
WHERE WorkBook.Company Like "*" & [Customers].[Company] & "*";) AS Expr1
FROM WorkBook
WHERE (((Exists (select 1 
       from Customers
WHERE WorkBook.Company Like "*" & [Customers].[Company] & "*";))<>False));

从工作簿中删除竞争对手

DELETE WorkBook.*, Exists (select 1 
       from Competitors
WHERE WorkBook.Company Like "*" & [Competitors].[Company] & "*";) AS Expr1
FROM WorkBook
WHERE (((Exists (select 1 
       from Competitors
WHERE WorkBook.Company Like "*" & [Competitors].[Company] & "*";))<>False));

如果您能提供关于如何将这些查询组合、创建并集或重写为单个项目的任何帮助,我们将不胜感激。

答案1

您没有说明您正在使用哪个版本的 Microsoft Access,但这应该适用。

您是否考虑过在 中运行这三个查询transaction?这些查询可以从 VBA 模块中的子例程执行,而子例程可以从表单或宏上的按钮执行。

您可以在这里找到有关交易声明的信息:https://msdn.microsoft.com/en-us/library/bb208950(v=office.12).aspx

相关内容