As MySQL doesn't support sub-selects or use of more than one table
DELETE statement, you should use the following approach to
delete rows from 2 related tables:
SELECT the rows based on some
WHERE condition in the main table.
DELETE the rows in the main table based on the same condition.
DELETE FROM related_table WHERE related_column IN (selected_rows)
If the total number of characters in the query with
related_column is more than 1,048,576 (the default value of
max_allowed_packet, you should split it into smaller parts and
DELETE statements. You will probably get the
DELETE by only deleting 100-1000
id's per time if the
related_column is an index. If the
related_column isn't an index, the speed is independent of the
number of arguments in the