Consulting

Results 1 to 4 of 4

Thread: Delete Query with two joins to a Query

  1. #1
    VBAX Regular
    Joined
    Jul 2016
    Posts
    25
    Location

    Delete Query with two joins to a Query

    Hi all,

    I'm trying to create a DELETE query with a table that has two joins to a Query. Is this possible?

    This is what I have so far but is not working.

    DELETE *FROM LV_TEST_UNQ
    WHERE EXISTS
        (SELECT *
          FROM vMST_Max_NotLV
          WHERE vMST_Max_NotLV.AccessionNumber = LV_TEST_UNQ.AccNo AND vMST_Max_NotLV.OrderCodes = LV_TEST_UNQ.TestCode);

    Any ideas welcomed

  2. #2
    VBAX Regular
    Joined
    Jul 2016
    Posts
    25
    Location
    I think I just figured this out via this query:


    DELETE *FROM LV_TEST_UNQ
    WHERE EXISTS
        (SELECT *
          FROM vMST_Max_NotLV
          WHERE vMST_Max_NotLV.AccessionNumber = LV_TEST_UNQ.AccNo)
    AND EXISTS
        (SELECT *
          FROM vMST_Max_NotLV
          WHERE vMST_Max_NotLV.OrderCodes = LV_TEST_UNQ.TestCode);

  3. #3
    Do you have a more optimized way to execute this DELETE query without using two EXISTS conditions?

  4. #4
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,255
    Location
    Hi Michael J. M,

    I have removed the spam from your signature, please don't spam here.

    If you add it back you will be banned from the forum.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •