$subQuery = $model :: query() -from(‘table1 as a‘ ) - getQuery(); $query = $model :: query() -from(‘table2 as b‘ ) -joinSub( $subQuery , ‘sub‘, ‘sub.id‘, ‘=‘, ‘b.id‘); View Code Enjoy it !
$subQuery = $model::query() ->from(‘table1 as a‘) ->getQuery(); $query = $model::query() ->from(‘table2 as b‘) ->joinSub($subQuery, ‘sub‘, ‘sub.id‘, ‘=‘, ‘b.id‘);View Code
Enjoy it !