当前位置 : 主页 > 手机开发 > ROM >

Laravel joinSub 子查询的写法

来源:互联网 收集:自由互联 发布时间:2021-06-10
$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 !

网友评论