Delete from multiple related tables on one id?

Valera P.

I have three tables.

  • Table 1 (table1_id, table1_name)
  • Table 2 (table2_id, table1_id, table2_name)
  • Table 3 (table3_id, table2_id, table3_name)

I want to delete all the information where table1_id = 33. How I also delete all table2 rows that have table1_id = 33 and also all table3 rows that have table2_id whose rows in Table 2 have table1_id = 33? What is the nicest and proper way to do that?

Sagar Shirke

If you are using sql server then you can go for option "Cascade Delete". Use this option for Table1 and Table2 it should work.

How to use Cascade Delete

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Delete rows from multiple tables as one query

From Dev

Delete row from 2 related tables

From Dev

Delete rows from two tables related

From Dev

Delete data from three different tables that is related

From Dev

Using SqlBulkCopy in one transaction for multiple, related tables

From Dev

Using SqlBulkCopy in one transaction for multiple, related tables

From Dev

Delete from multiple tables with MyISAM

From Dev

Delete from multiple tables, if has

From Dev

DELETE multiple tables where at least one is empty

From Dev

Postgresql delete multiple rows from multiple tables

From Dev

SQL Server 2008 R2: Delete duplicate rows from multiple tables and keep original one

From Dev

delete from 3 tables with one query

From Dev

MySQL, delete from multiple tables where id match and timestamp is older than current_time

From Dev

SQL, How to delete rows from related tables using a query?

From Dev

Joining multiple MySQL Tables with one relations ID

From Dev

MySQL - Delete from multiple tables using a UNION?

From Dev

Delete the same set of values from multiple tables

From Dev

Query to delete from multiple tables in Access

From Dev

LINQ Join to delete contents from multiple tables

From Dev

Delete rows from multiple tables in a database

From Dev

Query to delete from multiple tables in Access

From Dev

DELETE rows from multiple tables with JOIN in Mysql

From Dev

Delete records from multiple Access tables

From Dev

Delete from multiple tables with SQL in PHP

From Dev

update multiple tables from one csv and get row id after update_or_insert

From Dev

Querying related fields from Django Tables with One to Many Relationship

From Dev

Android Sqlite Delete related tables

From Dev

select from three tables with one common id

From Dev

Print counts from multiple tables in one SQL

Related Related

  1. 1

    Delete rows from multiple tables as one query

  2. 2

    Delete row from 2 related tables

  3. 3

    Delete rows from two tables related

  4. 4

    Delete data from three different tables that is related

  5. 5

    Using SqlBulkCopy in one transaction for multiple, related tables

  6. 6

    Using SqlBulkCopy in one transaction for multiple, related tables

  7. 7

    Delete from multiple tables with MyISAM

  8. 8

    Delete from multiple tables, if has

  9. 9

    DELETE multiple tables where at least one is empty

  10. 10

    Postgresql delete multiple rows from multiple tables

  11. 11

    SQL Server 2008 R2: Delete duplicate rows from multiple tables and keep original one

  12. 12

    delete from 3 tables with one query

  13. 13

    MySQL, delete from multiple tables where id match and timestamp is older than current_time

  14. 14

    SQL, How to delete rows from related tables using a query?

  15. 15

    Joining multiple MySQL Tables with one relations ID

  16. 16

    MySQL - Delete from multiple tables using a UNION?

  17. 17

    Delete the same set of values from multiple tables

  18. 18

    Query to delete from multiple tables in Access

  19. 19

    LINQ Join to delete contents from multiple tables

  20. 20

    Delete rows from multiple tables in a database

  21. 21

    Query to delete from multiple tables in Access

  22. 22

    DELETE rows from multiple tables with JOIN in Mysql

  23. 23

    Delete records from multiple Access tables

  24. 24

    Delete from multiple tables with SQL in PHP

  25. 25

    update multiple tables from one csv and get row id after update_or_insert

  26. 26

    Querying related fields from Django Tables with One to Many Relationship

  27. 27

    Android Sqlite Delete related tables

  28. 28

    select from three tables with one common id

  29. 29

    Print counts from multiple tables in one SQL

HotTag

Archive