To delete records of more than one table we can use joins. Joins are used to combine two table. Here, we will use join to delete the records from more than one table.
DELETE T1, T2 FROM T1 INNER JOIN T2 ON T1.key = T2.key WHERE condition
Here we used inner join to delete the records from two tables i.e., t1 and t2 depending on some where condition.
Suppose we have two table office and employees. Every employee have some office code. We have to remove all the details related two the offices and employees whose office code is 5. For this we will execute the following MySQL statement:
DELETE offices, employees FROM offices INNER JOIN employees ON employees.officeCode = employees.officeCode WHERE offices.officeCode = 5