Low stock alert
- SQL course
- Beginner
- Lesson 111/115
- 5 min
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
-- delete product
DELETE FROM inventory
WHERESample solution
DELETE FROM inventory
WHERE id = 3Expected 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
DELETE ____ inventory
WHERE id = 3;
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 |