SQL DELETE Statement
How do I delete records in SQL?
- DELETE permanently removes records from a table.
- DELETE can delete one or more records in a table.
- Use the WHERE clause to DELETE only specific records.
The SQL DELETE syntax
The general syntax is
To delete specific records append a WHERE clause:
DELETE table-name WHERE condition
SQL DELETE Examples
Problem: Delete all products.
Result: 77 records deleted.
Problem: Delete products over $50.
DELETE Product WHERE UnitPrice > 50
Result: 7 records deleted.
Problem: Delete customer with Id = 21.
DELETE Customer WHERE Id = 21
This is a common scenario in which a single record is deleted.
Result: 1 record deleted.