DELETE — Remove Data
The DELETE statement allows you to remove rows from a table.
You can delete one row, multiple rows, or all rows.
Syntax
DELETE FROM table_name
WHERE condition;
Important: Always use a WHERE clause unless you want to delete all rows.
Example 1: Delete One Employee
DELETE FROM employees
WHERE id = 1;
This deletes the employee with id = 1.
Example 2: Delete Employees in HR Department
DELETE FROM employees
WHERE department = 'HR';
This deletes all employees who are in the HR department.
Common Mistakes
Forgetting the WHERE clause
DELETE FROM employees;
Mistake: This will delete all employees from the table — be very careful!
Tip: Always include a WHERE condition to target specific rows:
DELETE FROM employees
WHERE id = 1;