mardi 24 février 2015

update table from another table's data

I have 2 tables : customers (customer,city_name,postal_code) and postal_codes(city_name,postal_code).


In the customers table the postal_code entries are missing but the city is there.


How can I update the customers table from the postal_codes table so the missing postal_code gets updated in the customers table where the postal_code is missing?


This may be a duplicate but I could not make work any of the suggestions from similar threads. They all use some kind of abbreviations for table names which I find hard to follow.


Tried this but it does not seem to work :



UPDATE customers
SET postal_code = postal_codes.postal_code
FROM postal_codes.postal_code INNER JOIN postal_codes.city_name ON customers.city_name

Aucun commentaire:

Enregistrer un commentaire