100 Days of SQL


Day 09 – DELETE statement

The SQL DELETE statement is used to delete one or more records from a table. The basic syntax for the DELETE statement is as follows:

DELETE FROM table_name WHERE condition;

Here, table_name is the name of the table from which you want to delete records, and condition specifies the criteria that must be met in order for the record to be deleted.

For example, suppose you have a table called customers with columns customer_id, first_name, last_name, and email_address. If you want to delete all records where the customer_id is equal to 5, you would use the following SQL statement:

DELETE FROM customers WHERE customer_id = 5;

This statement will delete all records in the customers table where the customer_id is equal to 5.

It is important to be cautious when using the DELETE statement, as it permanently removes data from a table. You should always double-check the WHERE clause to ensure that you are only deleting the records you intend to delete.