DELETE
The DELETE statement in SQL removes one or more records from a table based on a specified condition.
The basic syntax of the DELETE statement is as follows:
DELETE FROM table_name
WHERE condition;Let’s break down the components of the DELETE statement:
table_name: This is the name of the table from which you want to delete records.WHERE: This optional clause allows you to specify a condition that determines which records should be deleted.condition: This is the criteria that the records must meet to be deleted.
Example:
Suppose we have a table named employees as shown below:
Image scaled to 70%
and we want to delete the employee whose id is 1:
DELETE FROM employees
WHERE id = 1;In this example, only the record with an id of 1 will be deleted from the employees table and the updated table will look like this
Image scaled to 70%
Last updated on