Delete related records with one query

 

How to delete related records with one query (using ON DELETE CASCADE foreign key).

Delete related records with one query (using ON DELETE CASCADE foreign key).

 

This is only possible for the InnoDb tables where foreign keys are supported.

 

This command will delete a record in the `dept` table and all related records (with deptno = 1) in the child table `emp`:

Leave a Reply

Your email address will not be published. Required fields are marked *