By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,949 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,949 IT Pros & Developers. It's quick & easy.

InnoDB autodeletion ONLY when ALL Parent rows with ID=x are deleted, possible???

P: n/a
Hello,

I have a simple, but very general problem with MySQL using InnoDB tables.
I am sure you experienced folks can give me a solution...

Using foreign keys I want to delete a row in the table T_Child with WHERE
T_Child.Parent_ID=x
when ALL ROWS in the Parent table with ID=x are deleted.

(This behaviour is very useful
when Parent table is a list where T_Parent.ID is the ID column of the list
and hence, x can occur multiple times
in this column.)

As it is now, as soon as ONE row with ID=x in the Parent table is deleted,
all rows in the Child table
WHERE Parent_ID=x are also deleted.

thanks,

Peter
PS: I used ALTER TABLE T_Child ADD CONSTRAINT FOREIGN KEY Parent_ID
REFERENCES T_Parent (ID) ON CASCADE DELETE;

Both tables are InnoDB tables (otherwise nothing happens). I am using MySQL
4.0.16.
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.