Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
DELETE
On this page

DELETE

Example:

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

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

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page

DELETE

Example: