Deleting rows from 3 tables in MySQL table

peter.o

I've got 3 tables (I'll mention only attributes that are needed):

import id, date

import_head id, import_id

import_body id, import_head_id

import_head and import_body create one import item, import is created by dozens of import item Relations: import 1 <==> N *import_head* 1 <==> 1 *import_body* (ON DELETE CASCADE on every relation)

How can delete all import items when deleting row from import table?

When deleting import using DELETE FROM import WHERE id = ? error is thrown: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails - on import_head_id

Thanks a lot in advance

peter.o

I have changed entities in DB, so now there are only two tables:

import
import_item

I haven't found anything better, but it works.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Trigger to delete rows from related tables before deleting rows from actual table

From Dev

Efficiently deleting rows from one table where not matching another [MySQL]

From Dev

Deleting many rows from a big table MySql 5.5.46

From Dev

MySQL: deleting rows based on a condition with data from another table and NO JOIN

From Dev

Deleting multiple rows from a table

From Dev

Deleting multiple rows from a table

From Dev

Deleting rows from multiple tables with jQuery

From Dev

Deleting rows from two tables related by constraint

From Dev

MySQL join 3 tables and find "missing" rows in one table

From Dev

Insert rows into a table from another two tables separately in mysql

From Dev

mysql table not decreased in size after deleting rows

From Dev

Adding or deleting table rows with MySQL, jQuery and Ajax

From Dev

Script for deleting table rows not working in MySQL & PHP

From Dev

Find total number of rows using data from 3 tables, MySQL

From Dev

PostgreSQL: deleting rows referenced from another table

From Java

Deleting all rows from Cassandra cql table

From Dev

Issue deleting rows from displayed table

From Dev

mysql - Deleting Rows from InnoDB is very slow

From Dev

mysql - Deleting Rows from InnoDB is very slow

From Dev

Deleting related rows from other tables without primary key

From Dev

MYSQL : Mix data from 3 tables and JOIN with another table

From Dev

MySQL set column value from another table (JOIN 3 tables)

From Dev

MYSQL : Mix data from 3 tables and JOIN with another table

From Dev

Build a championship table in PHP from 3 MySQL tables

From Dev

Deleting Row from users table PHP MYSQL

From Dev

AJAX/Jquery not deleting row from MySQL table

From Dev

Deleting rows in HTML table

From Dev

How to get the Smallest value from the Top 3 rows of the table in mysql

From Dev

Select rows from a table based on results from two other tables in mySQL using PDO

Related Related

  1. 1

    Trigger to delete rows from related tables before deleting rows from actual table

  2. 2

    Efficiently deleting rows from one table where not matching another [MySQL]

  3. 3

    Deleting many rows from a big table MySql 5.5.46

  4. 4

    MySQL: deleting rows based on a condition with data from another table and NO JOIN

  5. 5

    Deleting multiple rows from a table

  6. 6

    Deleting multiple rows from a table

  7. 7

    Deleting rows from multiple tables with jQuery

  8. 8

    Deleting rows from two tables related by constraint

  9. 9

    MySQL join 3 tables and find "missing" rows in one table

  10. 10

    Insert rows into a table from another two tables separately in mysql

  11. 11

    mysql table not decreased in size after deleting rows

  12. 12

    Adding or deleting table rows with MySQL, jQuery and Ajax

  13. 13

    Script for deleting table rows not working in MySQL & PHP

  14. 14

    Find total number of rows using data from 3 tables, MySQL

  15. 15

    PostgreSQL: deleting rows referenced from another table

  16. 16

    Deleting all rows from Cassandra cql table

  17. 17

    Issue deleting rows from displayed table

  18. 18

    mysql - Deleting Rows from InnoDB is very slow

  19. 19

    mysql - Deleting Rows from InnoDB is very slow

  20. 20

    Deleting related rows from other tables without primary key

  21. 21

    MYSQL : Mix data from 3 tables and JOIN with another table

  22. 22

    MySQL set column value from another table (JOIN 3 tables)

  23. 23

    MYSQL : Mix data from 3 tables and JOIN with another table

  24. 24

    Build a championship table in PHP from 3 MySQL tables

  25. 25

    Deleting Row from users table PHP MYSQL

  26. 26

    AJAX/Jquery not deleting row from MySQL table

  27. 27

    Deleting rows in HTML table

  28. 28

    How to get the Smallest value from the Top 3 rows of the table in mysql

  29. 29

    Select rows from a table based on results from two other tables in mySQL using PDO

HotTag

Archive