SQL DELETE statement is used to delete existing records in a table.

SYNTAX

94.png

Where,

  • DELETE                                             : keyword used delete records from a certain table based on the where condition

  • Table_name                                      : The name of the table from where you want to fetch the data.

  • Column1Name, Column2Name         : The name of the columns of the table which you want to fetch.

NOTE: We must always use the WHERE clause with the DELETE query to eliminate the required rows, otherwise all the rows would be deleted.

EXAMPLE

Let us consider a demo database with table name Persons.

95.png
96.png

     The above Query will delete a record from table Persons where the FirstName is ‘Erichsen’;

Figure 28.1. DELETE QUERY & OUTPUT;

97.png
 

Figure 28.1. Select * from Persons;

 

PRACTICE YOURSELF 

98.png