I've got two tables with the following structure:
Person
- Id
- Name
Class
- Id
- PersonId
- Sequence
and some data:
Person
1 name1
2 name2
3 name3
Class
1 1 3
2 1 1
3 1 2
4 2 1
Class
table can contain multiple rows related to one row from Person
. PersonId
from Class
table is foreign key to Id
in Person
table. I'd like to delete data related to Person
with Id
1, so remove the 3 rows from Class
, and 1 row from Person
using one query.
How can I do that in SQL?