SkillByAIOpen interactive version →

Lesson 11 / 30

DELETE

Remove rows safely with DELETE and WHERE, previewing the affected rows with a SELECT first.

Deleting rows

DELETE FROM removes matching rows; the table itself stays.

DELETE FROM customers
WHERE id = 3;

Output:

Query OK, 1 row affected

Test with SELECT first

Before a risky UPDATE/DELETE, run the same WHERE clause in a SELECT first to confirm exactly which rows will be affected.

Quick check: What happens if you run `DELETE FROM customers;` with no WHERE?

  • Every row in the table is deleted
  • Nothing, MySQL requires a WHERE clause
  • Only the first row is deleted
  • Only rows created today are deleted
Answer

Every row in the table is deleted — MySQL doesn't require WHERE — omitting it deletes all rows.