在两个具有相同列名的表上创建VIEW时,如何避免MySQL中的重复列名错误
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'
答案 0 :(得分:4)
使用列名称的别名
CREATE VIEW db.VI_RegionCity AS SELECT
Region.Name as Region_name,
City.Name as City_name
...//rest of the query
答案 1 :(得分:1)
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