H
husain
Guest
Hello people! This is my first post here. I am a beginner in Access and I hope I can find the solution to my problem here.
I have two tables with a one to many relationship. The 'parent' table is called Orders and the related table is called OrderDetails. I have created a query that will list out all OrderID's that do not have corresponding records in the OrderDetails table.
What I want to do is delete all records from the Orders table that do not have corresponding records in the OrderDetails table so I converted this select query into a delete query. However, when I run it, I get this error: "Could not delete from specified tables."
The SQL for the select query:
SQL when I convert the above to a delete query:
Could someone please point out where I have made a mistake? Thanks 
I have two tables with a one to many relationship. The 'parent' table is called Orders and the related table is called OrderDetails. I have created a query that will list out all OrderID's that do not have corresponding records in the OrderDetails table.
What I want to do is delete all records from the Orders table that do not have corresponding records in the OrderDetails table so I converted this select query into a delete query. However, when I run it, I get this error: "Could not delete from specified tables."
The SQL for the select query:
Code:
SELECT Orders.OrderID
FROM Orders LEFT JOIN OrderDetails ON Orders.OrderID = OrderDetails.OrderID
WHERE (((OrderDetails.OrderID) Is Null));
SQL when I convert the above to a delete query:
Code:
DELETE Orders.OrderID, OrderDetails.OrderID
FROM Orders LEFT JOIN OrderDetails ON Orders.OrderID = OrderDetails.OrderID
WHERE (((OrderDetails.OrderID) Is Null));
