content_image/798239.jpg
(before the USING  clause) are deleted. The effect is that you can delete rows from many tables at the same time and have additional tables that are used only for searching: 

DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id; 

Or: 

DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id AND t2.id=t3.id; 

These statements use all three tables when searching for rows to delete, but delete matching rows only from tables t1  and t2 . 

The preceding examples use INNER JOIN , but multiple-table DELETE  statements can use other types of join permitted in SELECT  statements, such as LEFT JOIN . For example, to delete rows that exist in t1 that have no match in t2 , use a LEFT JOIN : 

DELETE t1 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL; 

The syntax permits .*  after each tbl_name  for compatibility with Access . 

If you use a multiple-table DELETE  statement involving InnoDB  tables for which there are foreign key constraints, the MySQL optimizer might process tables in an order that differs from that of their parent/child relationship. In this case, the statement fails and rolls back. Instead, you should delete from a single table and rely on the ON DELETE  capabilities that InnoDB  provides to cause the other tables to be modified accordingly. 

<img src='content_image/798239.jpg'>

## Note 

If you declare an alias for a table, you must use the alias when referring to the table: 

DELETE t1 FROM test AS t1, test2 WHERE ... 

Table aliases in a multiple-table DELETE  should be declared only in the table_references  part of the statement. Elsewhere, alias references are permitted but not alias declarations. 

Correct: 

DELETE a1, a2 FROM t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id; DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN t2 AS a2 WHERE a1.id=a2.id; 

Incorrect: 

DELETE t1 AS a1, t2 AS a2 FROM t1 INNER JOIN t2 WHERE a1.id=a2.id; DELETE FROM t1 AS a1, t2 AS a2 USING t1 INNER JOIN t2 WHERE a1.id=a2.id; 

Table aliases are also supported for single-table DELETE  statements beginning with MySQL 8.0.16. (Bug #89410,Bug #27455809) 

## 13.2.3 DO Statement 

DO expr  [, expr ] ... 

