Hello everyone, my English is not good, use the google translation, please understand.
Will the use joinWith, sql record debug bar, the discovery will be more out of a query.
If table table_a, table_b relationship table_a.classid = table_b.id
After using the following query
$query = info::find()->select(['table_a.*','table_b.name'); $query->joinWith('infoClass');
Sql generated as follows
SELECT * FROM `table_a` LEFT JOIN `table_b` ON `table_a`.`classid` = `table_b`.`id` LIMIT 20
Then it will be more than one query
SELECT * FROM `table_b` WHERE `id` IN ('3', '7')
The problem is that I have acquired the previous query table_b of the content.
So the second sql I personally see no need to query the database again.
I ask you, is how to avoid this secondary query. Or the secondary query is what is necessary?
Please answer, thank you.