Use of Delete to delete multiple tables
1. Delete all matching records with ID values in Table T2.
Delete T1 from T1, T2 where t1.id = t2.id
Or
Delete from T1 using T1, T2 where t1.id = t2.id
2. Find and delete no matching records in data table T2.
Delete T1 from T1 left join T2 on t1.id = t2.id where t2.id is null
Or
Delete from T1, using T1 left join T2 on t1.id = t2.id where t2.id is null
3. Find the data with the same record from the two tables and delete the data from both tables.
Delete T1, T2 from T1 left join T2 on t1.id = t2.id where t1.id = 25
Note that Delete T1, T1 in T2 from, and T2 cannot be aliases.
For example:
Delete T1, T2 from table_name as T1 left join table2_name as T2 on t1.id = t2.id where table_name.id = 25
Execution in the data is incorrect (MySQL version is not less than 5.0 is acceptable in 5.0)
The preceding statement is rewritten
Delete table_name, table2_name from table_name as T1 left join table2_name as T2 on t1.id = t2.id where table_name.id = 25
Execution in the data is incorrect (MySQL version earlier than 5.0 is acceptable in 5.0)
Appendix: MySQL 4.0.2 or above