Multi-Table Delete

This lesson demonstrates how to delete data from multiple tables.

Multi-Table Delete

We know how to delete data from a single table, however, if you are confronted with a situation where you want to delete data from one table and also any related data from other tables, you can employ the multi-table delete queries. An example scenario can be that when we delete an actor from our Actors table we also want all rows in the DigitalAssets table belonging to the deleted actor removed too.

Older Syntax

DELETE T1, T2

FROM T1, T2, T3

WHERE <condition>

Newer Syntax

Use the newer syntax as it reads better:

DELETE FROM T1, T2

USING T1, T2, T3

WHERE <condition>

Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/36lesson.sh and wait for the MySQL prompt to start-up.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.