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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting records from one table based on records in another.

Status
Not open for further replies.

MrPiccolo

Technical User
Mar 29, 2004
15
GB
Hi folks,
maybe i'm being dense(?!), but i need to delete 596 records from table #A using a list of corresponding record id's held in table #B as the criteria. So far Access won't allow me to run a delete query to perform the task.
(In other words both tables have identical record id formats but table #A holds thousands of records but the other (table B#) holds only 596.)

Any suggestions please as how to do this task??
Many Thanks
MrP
 
Are you saying the following is not working for you ?
DELETE A.* FROM [table #A] AS A INNER [table #B] AS B
ON A.[record id] = B.[record id]

An alternative:
DELETE FROM [table #A]
WHERE [record id] In (SELECT [record id] FROM [table #B])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Geoff,
The problem seems lie in the fact that there are two tables (linked by a 1-2-1 join), in the QBD; which causes the delete query to throw up the error message "specify the table to delete from" when a run query is initiated.
mrP
 
Thanks PH,
Your alternative method solved the problem nicely!
Mucho Gracias
MrP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top