MSDN SQL Documentation

DELETE Statement

The DELETE statement removes rows from a table based on a condition. If no WHERE clause is specified, all rows are removed.

Syntax

DELETE FROM table_name
[WHERE condition];

Key Points

Examples

1. Delete specific rows

DELETE FROM Employees
WHERE Department = 'Sales' AND HireDate < '2020-01-01';

2. Delete all rows (truncate equivalent)

DELETE FROM Logs;

3. Delete with LIMIT (MySQL)

DELETE FROM Sessions
WHERE LastActive < NOW() - INTERVAL 30 DAY
LIMIT 1000;

Interactive Playground