Updating a table based on joining another table

suggest change

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 the cities city column in order to get the city’s state code. This is then used to update the state_code column in the person table.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents