SQL DELETE Statement

How do I delete records in SQL?

  • DELETE permanently removes records from a table.
  • DELETE can delete one or more records in a table.
  • Use the WHERE clause to DELETE only specific records.

The SQL DELETE syntax

The general syntax is

DELETE table-name 

To delete specific records append a WHERE clause:

DELETE table-name 
 WHERE condition

PRODUCT
Id
ProductName
SupplierId
UnitPrice
Package
IsDiscontinued

SQL DELETE Examples

Problem: Delete all products.
DELETE Product
Result: 77 records deleted.

PRODUCT
Id
ProductName
SupplierId
UnitPrice
Package
IsDiscontinued
Problem: Delete products over $50.
DELETE Product
 WHERE UnitPrice > 50
Result: 7 records deleted.

CUSTOMER
Id
FirstName
LastName
City
Country
Phone
Problem: Delete customer with Id = 21.
DELETE Customer
 WHERE Id = 21

This is a common scenario in which a single record is deleted.
Result: 1 record deleted.


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas