【问题标题】:How to do this laravel subquery如何做这个 laravel 子查询
【发布时间】:2021-06-29 21:55:42
【问题描述】:

如何在 Laravel 中进行此查询:

SELECT * FROM posts 
    LEFT OUTER JOIN (SELECT * from subscribers where subscribers.post_id=2) 
    as sub ON sub.university_id = universities.id

【问题讨论】:

    标签: laravel orm subquery left-join laravel-8


    【解决方案1】:

    试试这个,我从sql to laravel query builder converter online得到那个

    DB::table('posts')
    ->leftJoin('(SELECT * from subscribers where subscribers.post_id=2) as 
    sub','sub.university_id','=','universities.id')
    ->get();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-08
      • 2018-07-06
      • 2019-11-02
      • 2021-11-16
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多