Quantcast
Viewing latest article 7
Browse Latest Browse All 17

Delete records from multiple tables

This is sample query to delete record from multiple tables.

Specify all joined tables to get the list but can specify records in which tables to be deleted.

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;

Reference

https://dev.mysql.com/doc/refman/8.0/en/delete.html (refer section – Multi-Table Deletes)


Viewing latest article 7
Browse Latest Browse All 17

Trending Articles