SQL DELETE

DELETE removes rows from a table. Like UPDATE, it acts on every row that matches WHERE, and on all rows if you leave WHERE out.

Updated December 1, 2026

Syntax

DELETE FROM table_name
WHERE condition;

Delete rows that match

Remove cancelled orders, then see what’s left.

DELETE FROM orders
WHERE status = 'cancelled';

Check the result:

SELECT status, COUNT(*) AS orders
FROM orders
GROUP BY status;
Result on the Desk & Co. (online store) sample data (2 rows)
statusorders
delivered7
shipped2

Delete using a subquery

Remove products that are out of stock and have never been ordered.

DELETE FROM products
WHERE stock = 0
  AND id NOT IN (SELECT product_id FROM order_items);

Check the result:

SELECT COUNT(*) AS products_left
FROM products;
Result on the Desk & Co. (online store) sample data (1 row)
products_left
8

Common mistakes

Practice DELETE interactively

Write real queries in your browser and get instant feedback in the lesson “UPDATE and DELETE” (Unit 9). New learners can start free from the first lesson.

Frequently asked questions

DELETE vs TRUNCATE vs DROP?

DELETE removes chosen rows. TRUNCATE removes all rows quickly (not in SQLite). DROP TABLE removes the table itself.

Should I delete or mark rows as deleted?

Many apps “soft delete” with a deleted_at column, so data can be restored and history kept.

Related SQL tutorials