0

我试图为我正在制作的游戏阶梯写这个声明。在我将团队名称添加到方程式之前,所有内部连接都有效。

SELECT tblMatch.AttackingTeam,
       tblMatch.DefendingTeam,
       tblTeam.TeamName As AttackingTeamName,
       tblTeam.TeamName As DefendingTeamName,
       tblGameMaps.MapName AS MapName,
       tblGameTypes.TypeShort AS TypeName,
       tblStyles.StyleShort AS StyleName,
       tblMatch.AttackingScore,
       tblMatch.DefendingScore
FROM tblMatch
INNER JOIN tblGameMaps
ON tblGameMaps.MapID = tblMatch.MapID
INNER JOIN tblGameTypes
ON tblGameTypes.TypeID = tblMatch.TypeID
INNER JOIN tblStyles
ON tblStyles.StyleID = tblMatch.StyleID
INNER JOIN tblTeam A
ON A.TeamID = tblMatch.AttackingTeam
INNER JOIN tblTeam B
ON B.TeamID = tblMatch.DefendingTeam
WHERE LadderID=$ladderID AND (DefendingTeam=$teamID OR AttackingTeam=$teamID)

我得到的错误是

“字段列表”中的未知列“tblTeam.TeamName”

数据库确实有一个名为 tblTeam 的表,其中有一列 tblTeamName。也许我只是看不到错误???

4

3 回答 3

2

您已经使用tblTeamAand的别名B,因此不要使用tblTeam.TeamNameuse 或者A.TeamName根据B.TeamName您的要求。

于 2013-06-16T11:08:22.237 回答
0

tblTeamName您在表格中有一个列,tblTeam并且SELECT您正在调用TeamName

   tblTeam.TeamName As AttackingTeamName,
   tblTeam.TeamName As DefendingTeamName,

以及需要给同一列两次别名

于 2013-06-16T11:10:22.490 回答
0

那为什么要写这行

tblTeam.TeamName As AttackingTeamName,

也许这就是问题所在(CTRL-F 然后输入“tblTeam.TeamName As AttackingTeamName”)

于 2013-06-16T11:10:22.957 回答