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';
精彩评论