开发者

Joining 2 Tables in a Database

I currently am making a dynamic query string that is comprised of whatever a user checks on a html form. There is 开发者_JS百科Country, District, Population, and Language.

When I select Country, District, and Population the query string SELECT Country, District, Population FROM City WHERE name ='Tulsa' is created. The problem is Country is in a different table.

How do I read from the City table and the Country table in the same query string?


Assuming both your City and Country tables have a CountryID; try this:

SELECT Country, District, Population
FROM City
INNER JOIN Country ON Country.CountryID = City.CountryID
WHERE City.name = 'Tulsa';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜