I want to write trigger before deletion to delete sub-children from same mysql table. My table is samp_c:

**ID** **Name** **key** **Sub-key**
  1      sample1   ab      0
  2      Sample2   bc      ab
  3      sample3   cd      NULL

So if i delete ID -1 row ,then it should be deleted ID -2 row also(self joined JOIN samp_c table samp_c.key = samp_c_child.sub-key). Please help me write trigger

  • 1
    This task cannot be performed in a trigger. Create self-referencing FOREIGN KEY with ON DELETE CASCADE. – Akina Sep 8 '20 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.