Answer the question
In order to leave comments, you need to log in
How to make a subquery in yii2 or how to join two queries?
Hello!
How to make a subquery in yii2?
I have two requests like this. How to merge two requests?
//Это первая
$subQuery = AreaSizes::find()->select(['name as SizeName'])
->from('area_sizes')
->innerJoin('area_sizes_rel','area_sizes_rel.size_id = area_sizes.id')
->all();
//Это вторая
$query = Areas::find()->select(['name as areaName'])
->from(['areas'])
->innerJoin('area_prices','area_prices.area_id = areas.id')
->innerJoin('area_sizes_rel', 'area_sizes_rel.area_id = areas.id')
->innerJoin('area_equipment', 'area_equipment.area_id = areas.id')
->innerJoin('area_photos','area_photos.area_id = areas.id')
//->where(['id' => $subQuery])
->asArray()
->all();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question