on子句中的未知列{0} [英] Unknown column {0} in on clause

查看:341
本文介绍了on子句中的未知列{0}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在MySQL数据库上做一些工作,并在收到错误时完全陷入困境

I am doing some work on a MySQL database and completely stumped on receiving the error

1054 - Unknown column 'Puzzles.PuzzleID' in 'on clause'

表和列名称均存在并且正确.我刚刚在Navicat的视觉设计师中创建了它.

Both the table and the column names exist and are correct. I just created it in Navicat's visual designer.

SELECT
`PuzzleCategories`.`PuzzleCategory`,
`Clients`.`BusinessName`,
`Puzzles`.`PuzzleNumber`
FROM
`Puzzles`
Inner Join `PuzzleCategories` ON `Puzzles`.`PuzzleCategoryID` = `PuzzleCategories`.`PuzzleCategoryID` ,
`Clients`
Inner Join `Publications` ON `Clients`.`ClientID` = `Publications`.`ClientID`
Inner Join `PublicationIssues` ON `PublicationIssues`.`PublicationID` =     `Publications`.`PublicationID`
Inner Join `PuzzleUsages` ON `PuzzleUsages`.`PuzzleID` = `Puzzles`.`PuzzleID` AND `PuzzleUsages`.`PublicationIssueID` = `PublicationIssues`.`PublicationIssueID`

推荐答案

如果您确定列名正确,则问题可能出在连接顺序上.听起来逗号的每一侧的连接都是单独构建的. (我不确定这是否可能甚至是可能,但这是我根据您提供的信息所做的唯一猜测)

If you're sure that the column names are right the problem may be from the order of the joins. It sounds like the joins each side of the comma are being built separately. (I'm not sure if this is likely or even possible but it's the only guess I have based on the info you give)

查询可以重组为:



SELECT
`PuzzleCategories`.`PuzzleCategory`,
`Clients`.`BusinessName`,
`Puzzles`.`PuzzleNumber`
FROM
`Clients`
INNER JOIN `Publications` ON `Clients`.`ClientID` = `Publications`.`ClientID`
INNER JOIN `PublicationIssues` ON `PublicationIssues`.`PublicationID` =   `Publications`.`PublicationID`
INNER JOIN `PuzzleUsages` ON`PuzzleUsages`.`PublicationIssueID` = `PublicationIssues`.`PublicationIssueID`
INNER JOIN `Puzzles` ON `Puzzles`.`PuzzleID` = `PuzzleUsages`.`PuzzleID`
INNER JOIN `PuzzleCategories` ON `Puzzles`.`PuzzleCategoryID` = `PuzzleCategories`.`PuzzleCategoryID`

反正读起来更好.

这篇关于on子句中的未知列{0}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆