GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
SQL Question (not necessarily GeoName)  XML
Forum Index -> FAQ - frequently asked questions
Author Message
dxg



Joined: 18/06/2011 06:20:43
Messages: 3
Offline

Table countries contains a list of country codes and corresponding country name.

I am attempting to add an additional column to the geonames allCountries table. The new column is defined as country_name varchar(60).

Example,
US = United States of America

Currently I have a list of all the country codes and their corresponding country name. I am attempting to insert the country_name into the appropriate tuple within the Geonames table, any help would be appreciated.


A desired result would look like the following,

SELECT DISTINCT country_code, country_name
FROM geonames
US = United States of America
ZA = South Africa
RO = Romania
.....


I attempted the following but it is majorly flawed

UPDATE geoname
SET country_name =
(SELECT country_name
FROM countries)
WHERE country_code =
(SELECT country_code
FROM countries)

marc



Joined: 08/12/2005 07:39:47
Messages: 4105
Offline

UPDATE geoname
SET country_name =
(SELECT country_name
FROM countries
WHERE countries.country_code =
geoname.country_code)

[WWW]
dxg



Joined: 18/06/2011 06:20:43
Messages: 3
Offline

That was a "duh!" question.

Thank you very much Marc.
 
Forum Index -> FAQ - frequently asked questions
Go to:   
Powered by JForum 2.1.5 © JForum Team