聯合多個刪除查詢或以其他方式組合

聯合多個刪除查詢或以其他方式組合

我有 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

相關內容