Duplicate column names in SQL query
How do I avoid a dup column name error in MySQL when creating a VIEW on two tables that both have the same column name as shown here
CREATE VIEW db.VI_RegionCity AS SELECT
Region.Name,
City.Name
FROM
db.Region Region,
db.City City
WHERE
Region.RegionCode = City.RegionCode
ERROR: Duplicate 开发者_高级运维column name 'Name'
Using alias for column name
CREATE VIEW db.VI_RegionCity AS SELECT
Region.Name as Region_name,
City.Name as City_name
...//rest of the query
CREATE VIEW db.VI_RegionCity AS SELECT
Region.Name AS RegionName,
City.Name AS CityName
FROM
db.Region Region,
db.City City
WHERE
Region.RegionCode = City.RegionCode
精彩评论