Lesson 11 / 28

DELETE

Remove rows, safely.

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?

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

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