-1

Two database tables:

  1. Continent table with ContinentID and ContinentName columns
  2. City table with CityID, CityName and ContinentName columns

Situation:

I want to combine the corresponding city to its continent. Like Europe (continent) has Denmark (country).

However, what's wrong with my SQL statement?

select 
    CountryID, CountryName 
from 
    Country 
where 
    Country.ContientID = Contient.ContientID;
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kindess
  • 49
  • 6
  • 1
    Are you sure that Denmark is in your City table? Your question mentions cities, but not countries. – Bulat Aug 09 '15 at 11:04
  • The tables you mention are `Continent` and `City`, while the rest of the question talks about continents and countries.... please clean up your question and make it be consistent and logic in itself .... – marc_s Aug 09 '15 at 11:23

1 Answers1

1

You actually need to join the tables

select CountryID, CountryName 
from Country 
inner join Contient on Country.ContientID=Contient.ContientID

You were probably trying the old, legacy implicit join syntax which would work like this

select CountryID, CountryName 
from Country, Contient
where Country.ContientID=Contient.ContientID

but you should not use that any more.

juergen d
  • 201,996
  • 37
  • 293
  • 362