开发者

Joining 2 Tables in a Database

开发者 https://www.devze.com 2023-02-16 06:08 出处:网络
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.

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

精彩评论

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