Please see my other Database Development articles.
Performing DELETE using a JOIN
One of the most common actions necessary when deleting records is to delete some using relationships.
One example of deleting via a relationship is utilizing a JOIN to isolate a recordset targeted for deletion.
In this example, I’ll first create two temporary tables which I’ll then populate with test records.
Then, I’ll display the contents of both table to serve as a references.
With the test tables populated with “parent” and “child” records, I’ll then JOIN the two tables to isolate and delete those children linked to the first parent.
Here a view of the code.