2010-08-03 263 views
1

我並沒有花太多時間在MySQL中,但我被要求查看我的教會網站的問題。它已經停機了很長一段時間,我正試圖恢復正常運行。原址是在Mambo 4.5.3中完成的,這是一箇舊版本。我會在某個時候升級它,但我只想暫時讓它運行。MySQl查詢問題

我目前在下面的查詢中建立了Mambo的問題。無論網站管理員何時嘗試訪問網頁,我都會收到錯誤消息:

'on子句'中的未知列'c.access'。

我已驗證列確實存在於指定的表中。現在我很難過。我打開了MySQL查詢分析器並粘貼了查詢,並得到了與代碼1054相同的錯誤消息。有沒有人有任何想法?

SELECT 
    c.*, 
    g.name AS groupname, 
    cc.name, 
    u.name AS editor, 
    f.content_id AS frontpage, 
    s.title AS section_name, 
    v.name AS author 
FROM 
    mos_content AS c, 
    mos_categories AS cc, 
    mos_sections AS s 
    LEFT JOIN mos_groups AS g ON g.id = c.access 
    LEFT JOIN mos_users AS u ON u.id = c.checked_out 
    LEFT JOIN mos_users AS v ON v.id = c.created_by 
    LEFT JOIN mos_content_frontpage AS f ON f.content_id = c.id 
WHERE 
    c.state >= 0 
    AND c.catid=cc.id 
    AND cc.section=s.id 
    AND s.scope='content' 
ORDER BY 
    s.title, 
    c.catid, 
    cc.ordering, 
    cc.title, 
    c.ordering 
LIMIT 
    0,10 
+0

所以你確定在MOS_CONTENT表中名爲'access'的列? – Fosco 2010-08-03 18:13:43

+0

該表mos_content應該有訪問列,我認爲沒有其他原因得到該錯誤 – cesarnicola 2010-08-03 18:14:16

回答

5
SELECT 
    c.*, 
    g.name AS groupname, 
    cc.name, 
    u.name AS editor, 
    f.content_id AS frontpage, 
    s.title AS section_name, 
    v.name AS author 
FROM 
    mos_content AS c 
    INNER JOIN mos_categories AS cc on c.catid=cc.id 
    INNER JOIN mos_sections AS s on cc.section=s.id 
    LEFT JOIN mos_groups AS g ON g.id = c.access 
    LEFT JOIN mos_users AS u ON u.id = c.checked_out 
    LEFT JOIN mos_users AS v ON v.id = c.created_by 
    LEFT JOIN mos_content_frontpage AS f ON f.content_id = c.id 
WHERE 
    c.state >= 0 
    AND s.scope='content' 
ORDER BY 
    s.title, 
    c.catid, 
    cc.ordering, 
    cc.title, 
    c.ordering 
LIMIT 
    0,10 
+2

哈哈,剛剛輸入完成相同的事情 – 2010-08-03 18:16:38

+0

+1:或用圓括號組加入 – Mchl 2010-08-03 18:16:59

+1

@Joe工作像一個魅力。謝謝! – 2010-08-03 18:18:48

0

error 1052消息文本其實是一樣的東西Column 'foo' in %s is ambiguous。它通常發生在連接具有相同名稱的列的表格並且您沒有表格前綴時引用它們。

: - ?