How to delete rows

The syntax of the DELETE statement

pre> DELETE [FROM] table_name [WHERE search_condition]

Delete one row

      DELETE FROM products WHERE productID = 6;
      

Delete multiple rows

      DELETE FROM products WHERE categoryID = 3;
      

Another way to delete multiple rows

      DELETE FROM categories WHERE categoryID > 3;
      

Use a subquery to delete all order items for a customer

      DELETE FROM orderItems 
      WHERE orderID IN (
        SELECT orderID FROM orders WHERE customerID = 1
      );
      

Description

Warning

Back