![联合多个删除查询或以其他方式合并](https://linux22.com/image/1505366/%E8%81%94%E5%90%88%E5%A4%9A%E4%B8%AA%E5%88%A0%E9%99%A4%E6%9F%A5%E8%AF%A2%E6%88%96%E4%BB%A5%E5%85%B6%E4%BB%96%E6%96%B9%E5%BC%8F%E5%90%88%E5%B9%B6.png)
我有 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