none
Running a Delete Query RRS feed

  • Question

  • I am trying to delete records from one table that does not have a related field from another table, but it is not allowing me to run the delete Query.  Is there something that is stopping me from running the Delete Query?

    Friday, November 3, 2017 5:49 PM

All replies

  • You need to post the SQL of your query.


    Build a little, test a little

    Friday, November 3, 2017 6:35 PM
  • You don't say what your query's SQL statement is, but it may be that you have built a non-updatable query.  For this sort of operation I would normally use the NOT EXISTS predicate and a correlated subquery rather than joining the tables.  Let's assume you have two tables named Customers and Orders, related on a column named CustomerID, and you wish to delete all rows from Customers where there is no referencing row in Orders, the query would be:

    DELETE *
    FROM Customers
    WHERE NOT EXISTS
        (SELECT *
         FROM Orders
         WHERE Orders.CustomerID = Customers.CustomerID);



    Ken Sheridan, Stafford, England

    Friday, November 3, 2017 6:47 PM