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

Deleting Data

Status
Not open for further replies.

Spicealdous

Technical User
Feb 25, 2003
9
0
0
GB
Please help!

Sorry if it is blindingly obvious!

I have 2 tables, lets call them A and B. In table A there is a list of Names plus other fields of info. In table B there are another list of names and fields of info. I want a delete query to delete all names in table A that match the names in table B.

I have set up a query and input the criteria as [table B]![Names] but this does not work and asks for the paremeter to be input.

Can anyone tell me what the hell I am doing wrong.

Thanks
 
I don't think you are going to need any criteria for this one. In your query, if you just join the two tables, then only the records that are in both tables will be selected. Which is what you are wanting to delete.

See if the following query selects the records you are looking for. If it does, replace the first link of the query with "DELETE FROM table_a".



SELECT * FROM table_a
WHERE EXISTS
(SELECT * FROM table_a JOIN table_b ON table_a.name = table_b.name)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top