The SQL DELETE statement allows you to delete a record from the database.
The DELETE command uses a WHERE clause. If you don’t use a WHERE clause, all rows in the table will be deleted. Again, as with the UPDATE statement, the syntax for a basic DELETE statement is similar to a SELECT statement.
SQL statement
DELETE FROM Individual WHERE IndividualId = '6'
Source Table
IndividualId | FirstName | LastName | UserName |
---|---|---|---|
1 | Fred | Flinstone | freddo |
2 | Homer | Simpson | homey |
3 | Homer | Brown | notsofamous |
4 | Ozzy | Ozzbourne | sabbath |
5 | Homer | Gain | noplacelike |
6 | Benny | Hill | funnyman |
Result
Now if we select all records from the table, we see that record 6 has been deleted.
IndividualId | FirstName | LastName | UserName |
---|---|---|---|
1 | Fred | Flinstone | freddo |
2 | Homer | Simpson | homey |
3 | Homer | Brown | notsofamous |
4 | Ozzy | Ozzbourne | sabbath |
5 | Homer | Gain | noplacelike |