View Single Post
Old 12-15-2007, 06:33 PM   #1 (permalink)
Haris
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default When a parent row is deleted..

For e.g, I have a table users linked with sessions and comments.

The comments and session has a foreign key of users.id related with comments.user and sessions.user

How would I delete the data from the child table if the data from the parent table is deleted.

In my case, how would I delete all the rows relating to user 5 in comments and sessions table when user 5 is deleted from the users table?

I am looking for a relationship method, not a query.

__________________
Necessity is the mother of invention.

My blog
Haris is offline  
Reply With Quote