不明白为什么要用name.city代码和"city.CountryCode = country.Code"的用法

问题描述 投票:0回答:0

我遇到了问题;

给定 CITY 和 COUNTRY 表,查询 CONTINENT 为“Africa”的所有城市的名称。

注意:CITY.CountryCode 和 COUNTRY.Code 是匹配的键列。

解决方案是;

SELECT city.NAME
FROM city
    INNER JOIN country
    ON city.CountryCode = country.Code
WHERE country.continent = 'Africa';

但我不明白为什么写“city.Name”而不是“NAME” 以及为什么“ınner joın”是由 writen “ON city.CountryCode = country.Code”执行的 为什么“ON city.POPULATION = country.POPULATION”和“ON city.NAME = country.NAME”的用法不起作用?

解决方案是;

SELECT city.NAME 从城市 INNER JOIN 国家 ON city.CountryCode = country.Code WHERE country.continent = '非洲';

但我不明白为什么写“city.Name”而不是“NAME” 以及为什么“ınner joın”是由 writen “ON city.CountryCode = country.Code”执行的 为什么“ON city.POPULATION = country.POPULATION”和“ON city.NAME = country.NAME”的用法不起作用?

sql inner-join
© www.soinside.com 2019 - 2024. All rights reserved.