如何做这个 laravel 子查询
Posted
技术标签:
【中文标题】如何做这个 laravel 子查询【英文标题】:How to do this laravel subquery 【发布时间】: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
【问题讨论】:
【参考方案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();
【讨论】:
以上是关于如何做这个 laravel 子查询的主要内容,如果未能解决你的问题,请参考以下文章