• Delete Dupes within table

    Author
    Topic
    #464420

    Hello. (Access 2007)
    I have a table of staff (tblStaff) including StaffID field, and a second table tblLeavers with a few of these staff members. How can I create a delete query that
    will delete those staff in the tblStaff that appear in the second table?
    I think this should be very simple, but I can’t get it to work?! Thanks greatly, Andy.

    Viewing 1 reply thread
    Author
    Replies
    • #1188615

      Try a query with this SQL:

      DELETE * FROM tblStaff WHERE StaffID In (SELECT StaffID FROM tblLeavers)

    • #1188617

      Hi. That’s great. (I got there two seconds before I read your answer – must be telepathy?)
      But why? Why can’t I just link the two tables in Query Design and delete * from tblStaff WHERE StaffID = tblLeavers!StaffID? Andy.

      • #1188625

        But why? Why can’t I just link the two tables in Query Design and delete * from tblStaff WHERE StaffID = tblLeavers!StaffID? Andy.

        It depends on the way the tables are set up. If the query as a select query is not updateable, you won’t be able to use it as a delete query.

    Viewing 1 reply thread
    Reply To: Delete Dupes within table

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: