SQL: UPDATE

Update


The UPDATE command in SQL is a DML (Data Manipulation Language) command. Other DML commands are: INSERT and DELETE.


Example: Update a record in the Employee table


	UPDATE Employee
	SET EmployeeLastName = 'Smith', City= 'New York'
	WHERE EmployeeID = 419031;
	

Output:

  Query OK, 1 row affected (0.01 sec)

Example: Update many record in the Customers table

The SQL command below will update any records in the Customers table who live in the state of Michigan with a telephone area code of 818. Their area code will be changed to 213.


	UPDATE Customers
	SET    AreaCode = 213
	WHERE  State = 'MI" 
	AND    AreaCode = 818  
	

Output:

  Query OK, 1,102 row affected (0.01 sec)