Question

I am using opencart, just got this error when trying to view customers in admin. I know nothing about SQL but I think it is telling me that I need to put cg.name somewhere.

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

Was it helpful?

Solution 2

Feel like an idiot but here's the answer:

I downloaded the wrong version of a mod... deleted the mod, deleted the problem...

OTHER TIPS

The name of the customer group is in the table customer_group_description so you need to join that table onto it as well and use that

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

Be sure to change the 1 for the language ID if it's incorrect

File: admin/model/sale/customer.php

~line 76

Replace:

$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)";

with:

$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)";

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top