CodeBlanks Logo Icon CodeBlanks

Low stock alert

Write queries that list low stock and clean up records.

Removing items

To remove a product from inventory you use DELETE. Discontinued products are deleted.

DELETE FROM inventory
WHERE id = 3;

This query removes product 3 from the inventory.

Rows are deleted from inventory. Only the rows where id = 3 holds are affected.

Removing items — details

Deletion cannot be undone. Make sure the product really should be removed. Always include WHERE.

Practice Removing items

Delete the product with id=3 from inventory.

Starter code

query.sql
-- delete product
DELETE FROM inventory
WHERE

Sample solution

query.sql
DELETE FROM inventory
WHERE id = 3

Expected output

1 satır silindi

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Delete row

Question
DELETE ____ inventory
WHERE id = 3;
Answer
DELETE FROM inventory
WHERE id = 3;

Explanation: The product is removed with DELETE FROM inventory WHERE id = 3.

2 Which statement removes a product?

  • UPDATE
  • DELETE Correct answer
  • INSERT
  • SELECT

Explanation: DELETE removes a row.

3 Low stock alert: match the terms

Term Meaning
DELETE delete
FROM table
WHERE condition
UPDATE update

All lessons in Beginner