Reputation: 301
This is part of my db schema
As you can see based on the schema a Vacancy can appear in one or more Faculties. I want to retrieve Vacancies that:
This way I can display Vacancies to their respective Faculty Admin (with the exception for Vacancies that appears on more than one Faculty will be displayed to a special Admin).
I tried using Vacancy::find()->where()
clause but it seems that where()
doesn't take COUNT()
as an argument.
Upvotes: 1
Views: 39
Reputation: 133370
for filter an aggregated result in a query you should use
Vacancy::find()
->leftJoin('vacancy.id = facultyvacancy.vacancy_id')
->having('count(*) = 1')->groupBy('your_column_for_grouping')
Upvotes: 1