Delete - High-Flying SQL Tips


SELECT, FROM

WHERE

INSERT

UPDATE

DELETE

CURSOR

Sponsored Links

Non-Sponsored Link Get Your Name In Space - a project by MIT and Georgia Tech

Sponsored Links

Delete

Here we look at the Delete command in SQL.

The Delete command in SQL allows us to delete data from a table in our database. It can be used to delete one row, multiple rows and all the rows.

In our first example, we delete a row where the ProductID is equal to 12345. This query would actually delete all the rows with a ProductID of 12345, so be careful.


-- Delete any row where ProductID = '12345'
DELETE FROM Products WHERE ProductID = '12345'


The following example will delete all the data in your database table.


-- Delete all the data in the table
DELETE FROM Products


The following example will delete rows where the price is between 11.00 and 14.00, including if the price is 11.00 or 14.00.


-- Delete all the rows where the
-- price is between 11.00 and 14.00 inclusively
DELETE FROM Products WHERE Price >= '11.00' AND Price <= '14.00'