Question: Delete a Record
Explore how to write basic SQL delete queries to remove specific records from a table. This lesson uses an Employees table example to demonstrate how to delete an employee by ID and verify the deletion. Learn practical skills to manage data cleanup confidently in SQL.
We'll cover the following...
Question
Given the following Employees table structure:
Employees
EmpID | EmpName | Salary |
1 | Susan Lee | 50000.00 |
2 | Alexa Smith | 60000.00 |
3 | Dana Amberson | 45000.00 |
4 | Sarah Ronald | 47000.00 |
Additional information
You are provided with a table named Employees that contains the following columns:
EmpID: Unique identifier for each employeeEmpName: The name of the employeeSalary: The salary of an employee
Let’s consider the Employees table structure, and here’s a task for you. One of the employees is moving on to a new opportunity. Her name is Alexa Smith, and her Employee ID is 2. You need to execute an SQL delete operation. Can you write a straightforward delete SQL query to remove Alexa’s record from the table?
It’s like tidying up the company’s digital files as Alexa moves on to her next adventure. Demonstrate your skills by completing this task!
Expected output
After deleting a record, you need to get all the records for verification. The output table should not contain the deleted record. The expected output is shown below:
EmpID | EmpName | Salary |
1 | Susan Lee | 50000.00 |
3 | Dana Amberson | 45000.00 |
4 | Sarah Ronald | 47000.00 |
Try it yourself
You can try to write a query in the following playground:
Hints
Below are some hints to help you understand these concepts better: