You can specify multiple tables in a DELETE statement to delete rows from one or more tables depending on the particular condition in the WHERE clause.
The syntax:
Example:
Let's consider two tables:
|
| ||||||||||||||||||||||||||||
I can delete the rows with ID-1,2,3 and 4 in table-1(firstName) and table-2(lastName) with the following query:
DELETE FROM firstName, lastName USING firstName INNER JOIN lastName
WHERE firstName.id=lastName.id
Voila!