F
F
F(x)2018-02-15 14:32:50
Yii
F(x), 2018-02-15 14:32:50

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

1 answer(s)
O
OKyJIucT, 2018-02-15
@OKyJIucT

->where(['in', 'name', $subQuery])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question