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!

Creating a Delete Query

Status
Not open for further replies.

mistereli

Technical User
Jan 13, 2003
73
0
0
US
In Access2000 I would like to create a delete query using as criteria a table of selected records to delete from two other tables.

Table #1 lists only the specific serial numbers that I would like use as the criteria. And the other two tables are Inventory and History. All have the serial number in common. The Inventory table has 200 records but the History has about 2000 (because there are multiple records for each serial number).

I've tried to create the delete query but with no success. I am limited in my knowledge of creating queries and would greatly appreciate anyones help. Thanks!
 
DELETE FROM INVENTORY WHERE SERIALNUM IN (SELECT SERIALNUM FROM TABLE#1)

DELETE FROM HISTORY WHERE SERIALNUM IN (SELECT SERIALNUM FROM TABLE#1)

It may be possible to do this in one query, but these should do what you want. Be sure to change the table and field names and just copy into the SQL view.

HTH

Leslie
 
I'm not clear if you want to delete records from History (for example) when the serial is NOT in Table1 OR if you want to delete where serial IS in Table1. Assuming the first option
Code:
Delete * From History
Where Serial NOT IN (Select Serial From Table1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top