laravel-eloquent-join
laravel-eloquent-join copied to clipboard
Column in where clause is ambiguous
Hi
Just installed the package and trying to use on a query. In particular I'm trying to avoid the 3rd problem you mention in the docs with "ambiguous column".
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous (SQL:
select projects.*, MAX(`customers`.`customername`) as sort
from `projects`
left join `customers` on `customers`.`customerid` = `projects`.`customer_id` and `customers`.`deleted_at` is null
where `status` = Open and `projects`.`deleted_at` is null
group by `projects`.`id`
order by sort asc
Projects and Customer both have the status column on them.
Models\Project::whereStatus('Open')
->orderByJoin('customer.customername')
->get();
Am I missing something in the setup?