I'm having a problem in deleting rows from several tables

Refresh

4 weeks ago

Views

33 time

1

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';

here's what I tried

1 answers

1

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