The UPDATE statement is used to
modify the data in a table.
UPDATE table_name SET column_name = new_value WHERE column_name = some_value |
Person:
LastName |
FirstName |
Address |
City |
Nilsen |
Fred |
Kirkegt 56 |
|
Rasmussen |
|
Storgt 67 |
|
We want to add a first name to the
person with a last name of "Rasmussen":
UPDATE Person SET FirstName = 'Nina' WHERE LastName = 'Rasmussen' |
Result:
LastName |
FirstName |
Address |
City |
Nilsen |
Fred |
Kirkegt 56 |
|
Rasmussen |
Nina |
Storgt 67 |
|
We want to change the address and
add the name of the city:
UPDATE Person SET Address = 'Stien 12', City = ' WHERE LastName = 'Rasmussen' |
Result:
LastName |
FirstName |
Address |
City |
Nilsen |
Fred |
Kirkegt 56 |
|
Rasmussen |
Nina |
Stien 12 |
|