Problem left join
LilD last edited by
Hi, I have a problem when I want to give another left join in addresses, those data are apparently taken from me and I can't exclude them and conflicts arise.
How could I just get what data I get from the address sheets and exclude the rest?
$queryBuilder = DB::table('customers') ->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id') ->leftJoin('addresses', 'customers.id', '=', 'addresses.customer_id') ->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status') ->addSelect('addresses.registration_number', 'addresses.vat_id') ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name'));
Integrity constraint violation: 1052 Column 'email' in where clause is ambiguous (SQL: select count(*) as aggregate from `customers` left join `customer_groups` on `customers`.`customer_group_id` = `customer_groups`.`id` left join `addresses` on `customers`.`id` = `addresses`.`customer_id` where (CONCAT(customers.first_name, " ", customers.last_name) like %
devansh-webkul last edited by
Just append the alias to email, because emails are two so its not able to detect which one should he take,