How to use SQL Delete statement

Web developer uses SQL Delete statement to remove one or more rows based on specified criteria:

DELETE FROM [table] WHERE [search_condition]

The following example removes a single matching row from the Clients table:

DELETE FROM Clients WHERE cli_id=’334-56-2289′

Note: If client record is linked to one or more records in other tables, for example ClientAccounts table, Web developer should delete linked records first and after that he/she can execute the query. If he/she attempts the run this this specific Delete statement, he/she’ll run into a database error.

The Delete and Update commands return a single piece of information: the number of affected records. Web developer can examine this value and uses it to determine whether the operation is successful or executed as expected.