UPDATE and DELETE

Contact Us or call 1-877-932-8228
UPDATE and DELETE

UPDATE

The UPDATE statement allows you to update one or more fields for any number of records in a table. You must be very careful not to update more records than you intend to!

Syntax

UPDATE table
SET field = value,
	field = value,
	field = value
WHERE conditions;

Code Sample:

InsertsUpdatesDeletes/Demos/Update.sql
-- Update an Employee

UPDATE Employees
SET FirstName = 'Nathaniel'
WHERE FirstName = 'Nat';

If the UPDATE is successful, the output will read something to this effect:

(1 row(s) affected)

DELETE

The DELETE statement allows you to delete one or more records in a table. Like with UPDATE, you must be very careful not to delete more records than you intend to!

Syntax

DELETE FROM Employees
WHERE conditions;

Code Sample:

InsertsUpdatesDeletes/Demos/Delete.sql
-- Delete an Employee

DELETE FROM Employees
WHERE FirstName = 'Nathaniel';

If the DELETE is successful, the output will read something to this effect:

(1 row(s) affected)
Next