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.
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.
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")
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