Wouter den Ouden
Wouter den Ouden

Reputation: 1523

Yii2 query all get value in join

I have an database with tablenames like this: tbl_accessoires_1, tbl_accessoires_2 etc. In my main table is a column that gives me the number for the table I have to join. But how do I get this value if I use ->all().

This is my query:

$query = (new Query())
   ->select([
       'a.id id',
       'a.soort soort',
   ])
   ->from('auto_new a')
   ->leftJoin('tbl_accessoires_--soort-- acc', 'acc.id = a.id')
   ->all();

So the a.soort in the select must be at the --soort-- Is there any way to do this?

If I only get one car it is possible because I could get the soort value before this query. but how do I do this when I want to get all cars

Upvotes: 2

Views: 523

Answers (1)

Wouter den Ouden
Wouter den Ouden

Reputation: 1523

So because it's not possible in my situation I've just made a new query to get the options. This will do for now because I don't really need the options when I get all cars.

Upvotes: 1

Related Questions