Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column in where clause is ambiguous #123

Open
iveoles opened this issue Aug 23, 2024 · 0 comments
Open

Column in where clause is ambiguous #123

iveoles opened this issue Aug 23, 2024 · 0 comments

Comments

@iveoles
Copy link

iveoles commented Aug 23, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant