I have to get my customers, And all customers Have a (customers groups) for example : customers/seller/guest/buyer.... And any customer Have a default Group , And I want to get the default group of this customer only when he is a Buyer but when he is a seller I want to get any other group (for sur when he is in this group) I should do this condition in mysql part . and this what I do but I get some problems
$searchQueryBuilder->addSelect("CASE
WHEN cg.id_group = 4 THEN c.id_default_group
ELSE cg.id_group END as id_group");
//dump($searchQueryBuilder);die;
$searchQueryBuilder->leftJoin(
'c',
'' . pSQL(_DB_PREFIX_) . 'customer_group',
'cg',
'c.id_customer = cg.id_customer '
);
$searchQueryBuilder->leftJoin(
'cg',
'' . pSQL(_DB_PREFIX_) . 'group_lang',
'gcl',
'id_group = gcl.id_group AND gcl.id_lang = '.(int) $this->context->language->id
);
I get a error when I use a alias column in LeftJoin