2013-05-31 34 views
0

我正在嘗試爲應用程序數據創建一個臨時表。當我運行子查詢它工作正常,但是當我臨時表的參數範圍內運行它失敗使用CROSS JOIN創建一個臨時表

錯誤代碼:在「where子句」

CREATE TEMPORARY TABLE CurrentApplications ENGINE=MEMORY AS 
(
SELECT *, planning_scheme.markus_ra, planning_scheme.metro_or_rural 
FROM application 
INNER JOIN key_table ON key_table.app_id = application.app_id 
INNER JOIN planning_scheme ON planning_scheme.ps_code = application.planning_scheme 

CROSS JOIN 
(
    SELECT key_table.app_id AS app_id2, planning_return.resp_authority AS resp_id 
    FROM key_table 
    INNER JOIN planning_return ON key_table.return_id = planning_return.return_id 

)getApplicationsForRespID 

WHERE application.app_id = getApplicationsForRespID.app_id 
AND key_table.is_current = 1 

1054未知列「getApplicationsForRespID.app_id」 )

回答

2

在您的交叉連接子查詢中,您有key_table.app_id AS app_id2,這意味着沒有字段getApplicationsForRespID.app_id存在。

改爲在WHERE條款中使用getApplicationsForRespID.app_id2

+0

是的,我剛剛發現,謝謝! –