以下是我用于尝试从3个表创建视图的代码。我收到错误“错误代码1052 fighterID不明确”。这是我尝试创建的第一个视图,我无法分辨出我为了正确填充视图而做错了什么。
CREATE VIEW championsList AS (
SELECT champions.fighterId, fighters.fighterId, weightClasses.weightClassId, fighters.firstName, fighters.LastName, weightClasses.weightClass
FROM champions, fighters
INNER JOIN fighters champions
ON
champions.fighterId = fighters.fighterId
INNER JOIN champions weightClasses
ON
champions.weightClassId=weightClasses.weightClass
fighters
1 Frank Smith
2 Fred Lewis
champions
1 2
2 1
weightClasses
1 heavyweight
2 bantemweight
ChampionsList
Frank Smith bantemweight
Fred Lewis Heavyweight
答案 0 :(得分:1)
为两列中的两列命名别名:
fighterId
我还将您的查询清理为我认为您的意图。