Answer the question
In order to leave comments, you need to log in
How to make SQL select from two related tables in Yii2?
Actually there are 2 tables:
$car_brand = Car::find()
->select('title, id, brand_id')
->with('car_brand')
->groupBy('brand_id')
->all();
SELECT * FROM `car_brand` WHERE `id` IN ( все айдишников моделей )
SELECT a.title as title, brand_id
FROM car_brand as a, car as b
WHERE b.brand_id = a.id
GROUP BY b.brand_id
Answer the question
In order to leave comments, you need to log in
With this request:
$car_brand = Car::find()
->select('title, id, brand_id')
->with('car_brand')
->groupBy('brand_id')
->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question