Search⌘ K
AI Features

Answer: Delete a Record

Understand how to delete specific records using the SQL DELETE statement combined with WHERE conditions. Learn to safely remove data without affecting entire tables and explore alternative methods like TRUNCATE and DROP for different deletion needs. Practice filtering data and verifying results to prepare for SQL interviews.

Solution

The solution is given below:

MySQL
/* The DELETE query to delete an existing record */
DELETE FROM Employees
WHERE EmpID = 2;
/* Retrieve the records from the Employees table */
SELECT * FROM Employees;

Explanation

The explanation of the solution code is given below:

  • Line 2: The DELETE FROM statement is followed by the table name, Employees, which will be modified.

  • Line 3: The WHERE clause specifies the condition on which we want to delete the record. We’ll specify the employee ID 2 in this clause. ...