We are no longer accepting contributions to Documentation. Please see our post on meta.
This draft deletes the entire topic.
Examples
-
You can also update data in a table based on data from another table:
UPDATE person SET state_code = cities.state_code FROM cities WHERE cities.city = city;
Here we are joining the
person
city
column to thecities
city
column in order to get the city's state code. This is then used to update thestate_code
column in theperson
table. -
You update all rows in table by simply providing a
column_name = value
:UPDATE person SET planet = 'Earth';
-
-
-
You can update multiple columns in a table in the same statement, separating
col=val
pairs with commas:UPDATE person SET country = 'USA', state = 'NY' WHERE city = 'New York';
Please consider making a request to improve this example.
Still have a question about UPDATE?
Ask Question
Sign up or log in
Save edit as a guest
Join Stack Overflow
Using Google
Using Facebook
Using Email and Password
We recognize you from another Stack Exchange Network site!
Join and Save Draftlang-sql