Deleting Data in SQL

The SQL ‘delete’ statement can be used for removing a record or records from a database table, which looks as follows.

DELETE FROM table_name
​WHERE where_condition

The following example deletes a record from the ‘person‘ table, as previously used in the examples for selecting, inserting and updating data, based on the ‘id’ being equal to 3.

WHERE id = 3;

The contents of the ‘person‘ table now looks like this.

id firstname lastname title dob
1 Fred Bloggs Mr 1980-05-05
2 Simon Smith Mr 1960-04-01
4 Fiona Adams Mrs 1985-05-19
5 John Smith Mr 1985-10-12

As with the ‘update‘ statement, multiple records can be deleted at once, if, for example, the ‘where’ condition specified ‘lastname’ to be equal to ‘Smith’, then two records would be deleted.