mysql delete join

Solutions on MaxInterview for mysql delete join by the best coders in the world

showing results for - "mysql delete join"
Lark
04 Mar 2018
1MySQL also allows you to use the INNER JOIN clause in the DELETE statement to delete rows from a table and the matching rows in another table.
2
3For example, to delete rows from both T1 and T2 tables that meet a specified condition, you use the following statement:
4
5DELETE T1, T2
6FROM T1
7INNER JOIN T2 ON T1.key = T2.key
8WHERE condition;
9Notice that you put table names T1 and T2 between the DELETE and FROM keywords. If you omit T1 table, the DELETE statement only deletes rows in T2 table. Similarly, if you omitT2 table, the DELETE statement will delete only rows in T1 table.
10
11The expression T1.key = T2.key specifies the condition for matching rows between T1 andT2 tables that will be deleted.
12
13The condition in the  WHERE clause determine rows in the T1 and T2 that will be deleted.