Jump to content

mysql trigger help


ngreenwood6

Recommended Posts

I was trying to create a trigger when I delete something from a table. Here is my table structure:

 

id

parent_id

name

 

The parent_id field is linked to the same table's id field. So the parent_id of any item in this table is going to be another rows id unless it is the parent (0). So something like this:

 

<-ROW->

1

0

Dog

 

<-ROW->

2

1

German Sheperd

 

Now when I delete dog I also need it to delete German sheperd because that item doesnt exist without its parent. I know when I run the delete I can just perform another delete for the children but I wanted to see if it can be done with a trigger. When I put the delete query in there it gives me this error : "Can't update table 'categories' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.". Anyone know if this is possible or not? Any help is appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.