当它存在时,on子句中的未知列

时间:2016-01-01 15:45:16

标签: mysql

在加入另一张桌子时遇到问题。

SELECT rank FROM  
    (
        SELECT highscores.playerID, (@rowID := @rowID + 1) AS rank 
        FROM highscores, (SELECT @rowID := 0) r
        JOIN overall ON highscores.playerID = overall.playerID
        WHERE skillID = ?
        ORDER BY skillExperience DESC, highscores.updateTime ASC
    ) data  
WHERE data.playerID = ?

Unknown column 'highscores.playerID' in 'on clause'存在的时候告诉我 xcodebuild clean VideoStationViewer Pods / SwiftyJSON (Debug) ✗ Check dependencies (37 ms) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Check dependencies target 'SwiftyJSON' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1 errored, 0 warning (38 ms) Pods / Alamofire (Debug) ✗ Check dependencies (38 ms) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Check dependencies target 'Alamofire' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1 errored, 0 warning (38 ms) Pods / OHHTTPStubs (Debug) ✗ Check dependencies (40 ms) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Check dependencies target 'OHHTTPStubs' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1 errored, 0 warning (47 ms) 。我已经在互联网上寻找解决这个问题的方法,但我找不到适用于我的解决方案。

行号是否导致问题?如果是这样我怎么能解决这个问题?

1 个答案:

答案 0 :(得分:2)

您必须首先使用整个表格加入highscores表:

SELECT rank FROM  
    (
        SELECT highscores.playerID, (@rowID := @rowID + 1) AS rank 
        FROM
          highscores JOIN overall ON highscores.playerID = overall.playerID,
          (SELECT @rowID := 0) r
        WHERE skillID = ?
        ORDER BY skillExperience DESC, highscores.updateTime ASC
    ) data  
WHERE data.playerID = ?

在您的原始查询中,您使用整个表格加入派生表r:

(SELECT @rowID := 0) r
JOIN overall ON highscores.playerID = overall.playerID

这不起作用,因为找不到highscores.playerID,因为highscores表将单独连接。