Professional SQL Editor For A Fraction Of The Price

Deleting data from a table

The delete statement is used to remove a row or rows of data from a database table.

Basic SQL Delete Syntax

A very basic delete query will remove all rows of data from a database table.

delete from table_name
SQL Delete Syntax With Conditions

To specify the results removed in a delete query the where clause can be used. All rows will be removed that satisfy the conditions of the where clause used.

delete from table_name
where column_one = 'condition' or column_two > 'condition' and column_three < 'condition'
Demo Table

Here is a very simple database table which holds information about people. The table is called Person. The table has only four rows and four columns to keep things simple in the examples.

first_name last_name city state
Nic Raboy Merced California
Jane Doe Newark New York
John Lee Las Vegas Nevada
Maria Campos Modesto California
Example SQL Queries

The following SQL statement will remove all rows of data in the Person table.

delete from Person

The following SQL statement will remove all rows of data in the Person table satisfying the condition that the person's state is California.

delete from Person
where state = 'California'

After executing the previous delete statement with conditions, the database table now has two rows of data remaining and looks like as follows:

first_name last_name city state
Jane Doe Newark New York
John Lee Las Vegas Nevada