0

hello...


i have 6 tables in database. now i am deleting product in product table. then how to delete all rows which is in another tables on this product id in single step.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by johny_d
0

Some database supports cascade delete, cascade update option. Mysql innodb engine may be supporting this. You need to modify relation between two tables and allow cascade delete.

click here for details

Edited by urtrivedi: n/a

0

mysql_query("DELETE p.*, t1.*, t2.*, t3.*, t4.*, t5.*, t6.*
FROM product AS p, table_1 AS t1, table_2 AS t2, table_3 AS t3, table_4 AS t4, table_5 AS t5, table_6 AS t6
WHERE p.id = $product_id
AND t1.product_id = $product_id
AND t2.product_id = $product_id
AND t3.product_id = $product_id
AND t4.product_id = $product_id
AND t5.product_id = $product_id
AND t6.product_id = $product_id")
or die(mysql_error());

This includes in the same query the delete from product table as well, so you don't have to put it in a different query

Edited by johny_d: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.