The DELETE statement is used to remove rows from a table.
Basic Syntax
- table_name → The table to delete from
- WHERE → Filters which rows to delete
⚠ Without WHERE, all rows will be deleted!
2.Example Table
Employees Table
| EmployeeID | Name | Department | Salary |
|---|---|---|---|
| 1 | John | IT | 5000 |
| 2 | Jane | HR | 4500 |
| 3 | Mike | IT | 6000 |
3.Delete a Single Row
Result: Jane’s record is removed.
4.Delete Multiple Rows
Result: All employees in IT department are removed.
5.Delete All Rows
- Removes all rows from the table
- Table structure and columns remain intact
- ⚠ Be careful; use TRUNCATE for faster deletion if needed
6.Delete Using JOIN
- Deletes rows in Employees that match ResignedEmployees table
7.Delete Using Subquery
- Deletes rows based on a subquery
8.Delete With TOP
- Deletes only the first N rows that meet the condition
- Useful for batch deletes
