Answer: Delete a Record
Find a detailed explanation of how to delete a record from a table using an SQL query.
We'll cover the following...
We'll cover the following...
Solution
The solution is given below:
MySQL
/* The DELETE query to delete an existing record */DELETE FROM EmployeesWHERE 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 FROMstatement is followed by the table name,Employees, which will be modified.Line 3: The
WHEREclause specifies the condition on which we want to delete the record. We’ll specify the employee ID2in this clause.Line 6: The
SELECTstatement can be used to retrieve the records to verify the working of our statement to delete the existing ...