Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete query based on two tables 1

Status
Not open for further replies.

joebloeonthego

Technical User
Mar 7, 2003
212
CA
I'm getting the 'operation must use an updatable query' error.

My problem is that I'm trying to delete all records in table A that have matching fields in table B (if it was just one field, I would do a IN(Select blah)).
Here's what I'm trying to do:
Code:
DELETE A.*
FROM A
INNER JOIN B 
ON A.reqdate = B.duedate AND A.plant = B.shipcode AND A.qty = B.ordqty AND A.partID = B.PN;

any suggestions?
 
I've never had that problem. The only thing I can suggest is try putting your crieteria into brackets... That's caused trouble with me before.

Hope this helps...

-------------------------
Just call me Captain Awesome.
 
well here's the actual code in access:
Code:
DELETE [FL 830 RMD].*
FROM [FL 830 RMD] INNER JOIN [FL 862 RMD] ON ([FL 830 RMD].Request_Date = [FL 862 RMD].Due_Date) AND ([FL 830 RMD].Qty = [FL 862 RMD].ORDER_QTY) AND ([FL 830 RMD].Part_ID = [FL 862 RMD].Part_ID) AND ([FL 830 RMD].Plant = [FL 862 RMD].Ship_To_Code);

I get the same problem with the brackets.
 
What are the PrimaryKeys of [FL 830 RMD] and [FL 862 RMD] ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try a subquery like (qSubQuery) (tested):
Code:
 Select A.ID
FROM A
INNER JOIN B
ON A.reqdate = B.duedate AND A.plant = B.shipcode AND A.qty = B.ordqty AND A.partID = B.PN;
Then
Code:
DELETE A.*
FROM A 
WHERE (((A.ID) In (Select ID from qSubQuery)))

(Assuming that A has a unique id)

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top