Link to home
Start Free TrialLog in
Avatar of marktoth
marktoth

asked on

How do I update a field in one table from a field in another table in orabcle

I have taken over a legacy system that now requires addresses to have the county name stored with them.  I have obtained a database with the city, stateabbreviation, county and postalcode in them, Imported the data into oracle 10g with the table name DEMOGRAPHICS
Now I need to update my Address table to fill in the county field
where the City, StateAbbreviation, PostalCode fields in the DEMOGRAPHICS = the City, StateAbbreviation, PostalCode fields in the Address Table.  Filling in the County field in the Address table with the County field in the DEMOGRAPHICS table
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image


update address
set county = d.county
from address a
inner join demographics d on a.city = d.city and a.stateabbreviation = d.stateabbreviation and a.postalcode = d.postalcode

Open in new window

Avatar of marktoth
marktoth

ASKER

thanks but I get the following error when I run the statement

Sql Command not properly ended, Line 2 Column 21
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And d.country should be d.county...
Thanks!
That saved me from having to look at about 102,000 records in our database!  Thanks!!!!!!!!!!!!!!!!!