2012-10-26 73 views
0

我正在使用opencart,試圖在管理員中查看客戶時出現此錯誤。我對SQL一無所知,但我認爲它告訴我需要將cg.name放在某處。'字段列表'中的未知列'cg.name'

Full error:

Notice: Error: Unknown column 'cg.name' in 'field list'

Error No: 1054

SELECT *, 
    CONCAT(c.firstname, ' ', c.lastname) AS name, 
    cg.name AS customer_group 
FROM oc_customer c 
LEFT JOIN oc_customer_group cg 
    ON (c.customer_group_id = cg.customer_group_id) 
ORDER BY name ASC 
LIMIT 0,100 

in /home4/pawpostc/public_html/system/database/mysql.php on line 49

+0

確表'oc_customer_group'確實包含'name'? –

+2

這意味着'oc_customer_group'中沒有'name'字段。嘗試在你的mysql控制檯中運行'desc oc_customer_group;'來查看你正在尋找的字段。 – ace

+0

nope,沒有名字字段。任何想法如何添加它呢? – Travis

回答

0

感覺像一個白癡,但這裏的答案:

我下載了一個國防部的錯誤版本...刪除的MOD,刪除的問題...

0

客戶組的名稱是表customer_group_description所以你需要加入該表到它,以及和使用

SELECT *, 
    CONCAT(c.firstname, ' ', c.lastname) AS name, 
    cgd.name AS customer_group 
FROM oc_customer c 
LEFT JOIN oc_customer_group_description cgd 
    ON (c.customer_group_id = cgd.customer_group_id) 
WHERE 
    cgd.language_id = 1 
ORDER BY name ASC 
LIMIT 0,100 

一定要改變1爲語言ID,如果它不正確

0

文件:管理/模型/銷售/ customer.php

〜線76

替換:

$sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname) AS name, cg.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group cg ON (c.customer_group_id = cg.customer_group_id)";

有:

$sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname) AS name, cg.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group_description cg ON (c.customer_group_id = cg.customer_group_id)";

相關問題