DELETE

The DELETE statement removes a record from a table. The basic syntax is

DELETE FROM table_name 
[WHERE condition] 

Like the UPDATE statement, the DELETE statement applies to all the records selected by the statement, so you need to be careful when you write this statement’s WHERE clause. If you specify a unique and never changing value in the clause, such as a primary key value, the statement will delete only the record you want. If you use a set of fields that may not be unique, you may delete more than you bargain for.

As is the case with the UPDATE statement, forgetting the WHERE clause completely is a common mistake when using the DELETE statement. If you omit the WHERE clause, the database removes every record from the table.

Get Visual Basic® .NET Database Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.