Hi,
I'm just starting with SQL and have quite a basic question.
I have a table People with the following fields:
PersonID, Name, CountryID
Sample data:
1 Bob 4
2 Jim 5
3 Bill 5
A Countries table with the following fields:
CountryID, Name, ContinentID
Sample data:
4 USA 1
5 UK 2
And a Continents table with the following fields:
ContinentID, Name
Sample data:
1 North America
2 Europe
Now I want to submit a query that will return the names of all the people in Europe.
I was thinking that this would be along the lines of:
But this doesn't seem to work - where have I gone wrong? With my sample data above the query should return Jim and Bill.
Many, many thanks,
Froskoy.
I'm just starting with SQL and have quite a basic question.
I have a table People with the following fields:
PersonID, Name, CountryID
Sample data:
1 Bob 4
2 Jim 5
3 Bill 5
A Countries table with the following fields:
CountryID, Name, ContinentID
Sample data:
4 USA 1
5 UK 2
And a Continents table with the following fields:
ContinentID, Name
Sample data:
1 North America
2 Europe
Now I want to submit a query that will return the names of all the people in Europe.
I was thinking that this would be along the lines of:
Code:
SELECT Name FROM People WHERE CountryID=(SELECT ContinentID FROM Countries WHERE ContinentID=2)
But this doesn't seem to work - where have I gone wrong? With my sample data above the query should return Jim and Bill.
Many, many thanks,
Froskoy.