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

How do I delete records in a one to many relationship?

Status
Not open for further replies.

donnew

IS-IT--Management
Jul 5, 2001
5
US
Good Morning! Have 2 tables; table#1 contains a field with a unique strings (numbers) and the table#2 has the same field but with many instances of the various unique strings. What I need to do is delete all instances of the strings in table#2 that match those unique strings in table#1. Have tried delete query but have not been successful - any help is greatly appreciated.

Don
 
When you created the relationship did you check cascading delete. With Cascading delete if you delete a record from the one side, it will delete all records on the many side that have that record unique ID. Try this and let me know if you need more help.
 
Use an IN list, which can be a subquery with the list of ID's you want to delete.

delete from table#2
where theID IN (select theID from table#1)
 
Thanks to all that helped, we were successful. I learned a lot on this problem and can now move forward. Thanks again!

Don
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top