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

Delete Parent Records with no Matching Child Records 2

Status
Not open for further replies.

tennisguy

Instructor
May 5, 2003
26
US
Hello!

I have a Projects table with 11 project records. I have an Employees table with 25 records. Each project has an ID (Project ID) and each employee is assigned to work on one project (Project_ID Number). The tables are related from Project ID in Projects to Project_ID Number in Employees.

What I would like to do is delete those project records that have no matching records in the employees table. In other words, I'd like to delete projects from the Projects table that no employee is working on.

I'm thinking that a delete query may be possible, but not sure how to lay out the design view's criteria to do this.

Thanks,
Michael
 
Something like this ?
DELETE FROM Projects WHERE [Project ID] NOT IN (SELECT [Project_ID Number] FROM Employees);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top