Web www.tizag.com

SQL - Update

The update clause updates column values of a table. Update requires a conditional statement to select the row to be updated.

SQL Code:

UPDATE employees
SET Lastname = 'Fletcher', Firstname = 'Ron'
WHERE id = '11';

SQL Table:

IDLastnameFirstnameTitle
11FletcherRonmanager

Here we changed record 11, our manager, to a new manager.

SQL - Updating Multiple Rows

With the use of expressions and operators, update allows for the manipulation of several rows at once.

SQL Code:

UPDATE employees
SET Title = UPPER(Title);

SQL Table:

IDLastnameFirstnameTitle
1JohnsonDavidCREW
2HivelyJessicaCREW
9HicksFreddyCREW
10HarrisJoelCREW
11DavisJulieMANAGER

Using the UPPER expression we changed our Title field to all capital letters. Update also supports the use of subqueries.





New - Tizag.com Forums!
Recent Forum Topics: