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!

deleteing rows from two or more tables

Status
Not open for further replies.

bramsey

Programmer
Aug 29, 2001
6
US
Is it possible to delete records in two or more tables with one delete statement? I have my data split out into several tables. In some instances, data in a second or third table may need to be deleted when data in the first is deleted. What is the best way to go about this? Thanks for any help.
 
bramsey:

It all depends on your database. Some databases support an "on delete cascade" addition to the foreign key on a child table. When a row is deleted from the parent table, all associated rows in the child are automatically deleted.

Also, if your database supports triggers on a delete you can take some action such as deleting data in other tables.

Regards,

Ed
 
Thank you, that is what I thought. I will just use the cascade delete. I guess the only other way would be to write two or three seperate delete statements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top