Reputation: 23
I want to delete all the rows which have productid = 'value' from several tables so I tried to join between them but gives me an error
sql command not properly ended
so I was asking if this could actually work and if not can anyone tell me how should I do such a thing?
DELETE FROM
products, products_admin, products_category, products_seller, categories
USING
products
JOIN
products_admin ON products_admin.productid = products.productid
JOIN
products_category ON products_category.productid = products.productid
JOIN
products_seller on products_seller.productid = products.productid
JOIN
categories on categories.productsid = products.productid
WHERE
products.productid = 'value';
Upvotes: 1
Views: 52
Reputation: 469
If you have foreign keys defined with ON DELETE CASCADE
, deleting from products table will delete records from all associated tables. See https://www.techonthenet.com/oracle/foreign_keys/foreign_delete.php
Upvotes: 1