Answer the question
In order to leave comments, you need to log in
How to filter by quantity in yii2?
Organized a selection from several tables (based on relations). It worked well, but there is one more task, you need to filter out those companies in which there are open vacancies. That is, if the company's vacancy count is greater than zero, then show this company.
Let me tell you a little about the project.
This is a work site. The site has vacancies and companies. A person registers, and creates two profiles, one for his other company. After can add vacancies. Companies are displayed separately vacancies separately.
Each vacancy has a uid field by which you can make a comparison. Like everything, if I answer questions.
Answer the question
In order to leave comments, you need to log in
Based on the date of the question, I will assume that it is no longer relevant, but suddenly someone needs it ...
What prevents you from making a condition in a connection?
'company'=>array(self::HAS_MANY, 'Company', 'company_id',
'group' => 'company_id',
'having' => 'COUNT(company_id) > 0',
'condition'=>'is_active=1');
SELECT seller_id, COUNT(seller_id) FROM vsellers_categories GROUP BY seller_id HAVING COUNT(seller_id) > 0;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question