Friday, 23 August 2013

SQL HAVING Unknown column

SQL HAVING Unknown column

I'm using WHERE XXX IN (SQL), so (SQL) must select only one Column
In this case I'm select some customer_id from a group, and those customer
only belongs to that group only
WHERE `id_customer` IN(
SELECT g.`id_customer` // this must select *only one* column
FROM ps_customer_group AS g
Group By g.`id_customer`
Having COUNT(g.`id_customer`) = 1
AND g.`id_group`=3 // **- Unknown column 'g.id_group' in 'having clause'**
)
the raw data look like this, btw this is not the result

No comments:

Post a Comment